2

I followed this instruction to configure Cuda but this step I tried to write the lines

To configure the CUDA environment for all users (and applications) on your system create the file (use sudo and a text editor of your choice)

/etc/profile.d/cuda.sh

with the following content,

export PATH=$PATH:/usr/local/cuda/bin export CUDADIR=/usr/local/cuda

but got "/etc/profile.d/cuda.sh" is a directory

I tried to run Cuda example and got

Error: target directory missing
Usage: cuda-install-samples-11.1.sh <target directory>
       Will append NVIDIA_CUDA-11.1_Samples to <target directory>

i tried to write in bashrc the following

export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64
PATH=${CUDA_HOME}/bin:${PATH} 
export PATH 

Edit

i tried to run a sample to test cuda by using this command

./cuda-install-samples-11.1.sh

but got

Error: target directory missing
  Usage: cuda-install-samples-11.1.sh <target directory>
   Will append NVIDIA_CUDA-11.1_Samples to <target directory>

Edit 2

i tried to run this command

./cuda-install-samples-11.1.sh /home/user/NVIDIA_CUDA-11.1_Samples

but got

bash: ./cuda-install-samples-11.1.sh: No such file or directory

enter image description here

sam
  • 1,333
  • Well, if it's an empty directory, just delete it and make the file. However, the instructions I see from Nvidia put the ...cuda/bin at the beginning of the PATH, not the end. At the beginning allows adding links to old/untested versions of gcc etc. without clobbering the system default gcc (which is expected to be able to rebuild the Nvidia drivers upon kernel update). – ubfan1 Nov 01 '20 at 00:10
  • thanks for replying but excuse me how can I know that directory is empty? I'm confusing about the difference between directory and folder. – sam Nov 01 '20 at 00:14
  • Navigate there in the Files gui, or from a terminal, ls /etc/profile.d/cuda.sh to see what's in the directory, if anything. The extensions don't really mean anything, although conventionally, directories are never named ...sh, just to avoid confusion. driectory and folder are the same thing, just different terminology. – ubfan1 Nov 01 '20 at 01:29
  • Please edit your question and add in the command that you are running for the CUDA examples. Also, make sure you install the glut stuff needed for it. sudo apt-get install freeglut3-dev – Terrance Nov 01 '20 at 04:30
  • i will edit the post but what is glut do? – sam Nov 01 '20 at 04:31
  • When you're making the example files so far that I have found is that both glut and glfw3 are needed. These are OpenGL applications that help the graphics show up. For glfw3 it is sudo apt install libglfw3-dev Most of this is going to take a while to learn. I am always learning mine so I won't be able to help you on all of it as I cannot actually use CUDA for Tensorflow on my system since my video card doesn't support Tensor, etc. – Terrance Nov 01 '20 at 04:37
  • i checked it and it is installed already – sam Nov 01 '20 at 04:37
  • https://askubuntu.com/questions/1077061/how-do-i-install-nvidia-and-cuda-drivers-into-ubuntu Visit that and you might need to reinstall your CUDA. The newest answer I wrote there should work with 18.04 and CUDA 11.1. It installed the samples automatically for me. I have tried to make this all easy for people to use. Others have tried to answer in there, but I do recommend that you look at the answer for 20.04 and CUDA 11.1 that I recently wrote. 4 of the answers there are all mine. – Terrance Nov 01 '20 at 04:39

1 Answers1

4

The directory /etc/profile.d/cuda.sh should be a file, so first remove that directory but be extremely careful when deleting directories:

sudo rm -Rf /etc/profile.d/cuda.sh

Add the following to the bottom of your ~/.profile (per user) or add it to a file called /etc/profile.d/cuda.sh (global) and restart your system:

# set PATH for cuda 11.1 installation
if [ -d "/usr/local/cuda-11.1/bin/" ]; then
    export PATH=/usr/local/cuda-11.1/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
fi

Then for the cuda-install-samples-11.1.sh <target directory> command when you use the .run file or .deb file installation it defaults to ~/NVIDIA_CUDA-11.1_Samples so run that command as:

./cuda-install-samples-11.1.sh ~/NVIDIA_CUDA-11.1_Samples

Or before you run the above command make sure it is executable by running:

chmod +x cuda-install-samples-11.1.sh
Terrance
  • 41,612
  • 7
  • 124
  • 183
  • many thanks for you .. if you please i hope you can help me in this https://askubuntu.com/questions/1288910/gpu-with-cuda-problem – sam Nov 03 '20 at 03:33