
ตัวอย่างง่ายๆหลายประการสำหรับชุดเครื่องมือเครือข่ายประสาท (Pytorch, TensorFlow ฯลฯ ) เรียกผู้ประกอบการ CUDA ที่กำหนดเอง
เราให้บริการหลายวิธีในการรวบรวมเมล็ด CUDA และเสื้อคลุม CPP ของพวกเขารวมถึง JIT, Setuptools และ CMake
นอกจากนี้เรายังมีรหัส Python หลายรหัสเพื่อเรียกเมล็ด CUDA รวมถึงสถิติเวลาเคอร์เนลและการฝึกอบรมแบบจำลอง
สำหรับสถิติเวลาที่แม่นยำยิ่งขึ้นคุณควรใช้ NVPROF หรือ NSYS เพื่อเรียกใช้รหัส
ไม่สามารถมั่นใจได้ว่าจะประสบความสำเร็จในสภาพแวดล้อมอื่น ๆ
├── include
│ └── add2.h # header file of add2 cuda kernel
├── kernel
│ └── add2_kernel.cu # add2 cuda kernel
├── pytorch
│ ├── add2_ops.cpp # torch wrapper of add2 cuda kernel
│ ├── time.py # time comparison of cuda kernel and torch
│ ├── train.py # training using custom cuda kernel
│ ├── setup.py
│ └── CMakeLists.txt
├── tensorflow
│ ├── add2_ops.cpp # tensorflow wrapper of add2 cuda kernel
│ ├── time.py # time comparison of cuda kernel and tensorflow
│ ├── train.py # training using custom cuda kernel
│ └── CMakeLists.txt
├── LICENSE
└── README.md การเจียระไน
เรียกใช้รหัส Python โดยตรง
setuptools
python3 pytorch/setup.py installcmake
mkdir build
cd build
cmake ../pytorch
makeเปรียบเทียบเวลาทำงานเคอร์เนล
python3 pytorch/time.py --compiler jit
python3 pytorch/time.py --compiler setup
python3 pytorch/time.py --compiler cmakeรุ่นรถไฟ
python3 pytorch/train.py --compiler jit
python3 pytorch/train.py --compiler setup
python3 pytorch/train.py --compiler cmakecmake
mkdir build
cd build
cmake ../tensorflow
makeเปรียบเทียบเวลาทำงานเคอร์เนล
python3 tensorflow/time.py --compiler cmakeรุ่นรถไฟ
python3 tensorflow/train.py --compiler cmakePytorch 自定义 cuda 算子教程与运行时间分析 pytorch 编译并调用自定义 cuda 算子的三种方式 pytorch 自定义反向传播
Q. ผู้นำเข้า: libc10.so: ไม่สามารถเปิดไฟล์วัตถุที่แชร์ได้: ไม่มีไฟล์หรือไดเรกทอรีดังกล่าว
A. คุณต้องimport torchก่อนimport add2
Q. tensorflow.python.framework.errors_impl.notfounderror: build/libadd2.so: สัญลักษณ์ที่ไม่ได้กำหนด: _ztin10tensorflow8opkernelele
A. ตรวจสอบว่า${TF_LFLAGS}ในCmakeLists.txtถูกต้องหรือไม่