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,413

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
  • 43,712