Wednesday 25 July 2018

How to run CUDA Program on Remote Machine

                   In this post, we will see how to run CUDA program on remote machine i.e. to run CUDA program on a system which doesn't have GPU and doesn't have CUDA installation and you want to use gpu of another system in  your network.


Follow the following steps:

1. Open Terminal

2. Get log in to remote system which has GPU and CUDA installed in it.
e.g. ssh student@10.10.15.21

3. Once you get logged in to system, create a cuda file with  extension .cu and write code in it.

e.g. cat >> sample.cu
Write code here
Press Ctrl+D to come outside the cat command.

4. Compile CUDA program using nvcc command.
e.g. nvcc sample.cu

5. It will create executable file a.out. Rut it.
e.g. ./a.out


When you are compiling using nvcc command, you may get compiler error “nvcc command not found”

In this case, on remote machine, of which you are using GPU,
you have to run following commands:

Open the terminal and type:
gedit ~/.bashrc  

This will open .bashrc for editing. 

Note: You have check path of CUDA bin folder. Suppose path is /usr/local/cuda-8.0/bin

Add the following to the end of your .bashrc file.
export PATH="$PATH:/usr/local/cuda-8.0/bin"
 
This sets your PATH variable to the existing PATH plus what you add to the end.
Run following command  to reload the configuration.
source ~/.bashrc 





No comments:

Post a Comment