Gorgonia comes with CUDA support out of the box. However, usage is specialized. To use CUDA, you must build your application with the build tag
cuda, like so:
go build -tags='cuda' .
Furthermore, there are some additional requirements:
- CUDA toolkit 9.0 is required. Installing this installs the
nvcccompiler which is required to run your code with CUDA.
- Be sure to follow the post-installation steps
go install gorgonia.org/gorgonia/cmd/cudagen. This installs the
cudagenwill generate the relevant CUDA related code for Gorgonia. Note that you will need a folder at
- The CUDA ops must be manually enabled in your code with the
runtime.LockOSThread()must be called in the main function where the VM is running. CUDA requires thread affinity, and therefore the OS thread must be locked.
nvcc only plays well with
gcc version 6 and below (the current version is 7), this is also quite helpful:
sudo ln -s /path/to/gcc-6 /usr/local/cuda-9.0/bin/gcc