negativo17 / cuda

NVIDIA Compute Unified Device Architecture Toolkit
14 stars 1 forks source link

Cannot find nvcc when building NVIDIA CUDA 9.1 samples on Fedora 27 #10

Closed kkalavantavanich closed 6 years ago

kkalavantavanich commented 6 years ago

Hi, I am trying to install cuda 9.1 on Fedora 27. I wasn't able to build the NVIDIA CUDA samples. I suspect that the Ma`kefile wasn't able to find CUDA and its libraries.

I enabled the repository according to your website using:

dnf config-manager --add-repo=https://negativo17.org/repos/fedora-nvidia.repo

and did not forget to update after enabling the repo.

Here is the list of currently installed repos; not sure if any of the repos are conflicting:

[~/NVIDIA_CUDA-9.1_Samples]$ dnf repolist
Last metadata expiration check: 1:43:45 ago on Tue 27 Mar 2018 02:05:12 AM +07.
repo id                              repo name                                               status
WineHQ                               WineHQ packages (Fedora 26)                                288
code                                 Visual Studio Code                                          29
*fedora                              Fedora 27 - x86_64                                      54,801
fedora-nvidia                        negativo17 - Nvidia                                        201
heliocastro-hack-fonts               Copr repo for hack-fonts owned by heliocastro                2
mysql-connectors-community           MySQL Connectors Community                                  15
mysql-tools-community                MySQL Tools Community                                       17
mysql57-community                    MySQL 5.7 Community Server                                  19
*rpmfusion-free                      RPM Fusion for Fedora 27 - Free                            574
*rpmfusion-free-updates              RPM Fusion for Fedora 27 - Free - Updates                  199
*rpmfusion-nonfree                   RPM Fusion for Fedora 27 - Nonfree                         205
*rpmfusion-nonfree-updates           RPM Fusion for Fedora 27 - Nonfree - Updates                51
sublime-text                         Sublime Text - x86_64 - Stable                               1
*updates                             Fedora 27 - x86_64 - Updates                            12,099
vbatts-bazel                         Copr repo for bazel owned by vbatts                          2

I installed cuda using:

sudo dnf install cuda cuda-devel cuda-cudnn cuda-cudnn-devel

The installation seems to be successful as no error messages appeared. nvcc is also installed:

[~/NVIDIA_CUDA-9.1_Samples]$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85

However, when I run the CUDA samples, nvcc cannot be found for some reasons:

~/NVIDIA_CUDA-9.1_Samples]$ make
make[1]: Entering directory '~/NVIDIA_CUDA-9.1_Samples/0_Simple/cudaOpenMP'
/usr/local/cuda-9.1/bin/nvcc -ccbin g++ -I../../common/inc  -m64    -Xcompiler -fopenmp -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_70,code=compute_70 -o cudaOpenMP.o -c cudaOpenMP.cu
make[1]: /usr/local/cuda-9.1/bin/nvcc: Command not found
make[1]: *** [Makefile:303: cudaOpenMP.o] Error 127
make[1]: Leaving directory '~/NVIDIA_CUDA-9.1_Samples/0_Simple/cudaOpenMP'
make: *** [Makefile:52: 0_Simple/cudaOpenMP/Makefile.ph_build] Error 2

Checking the directory in question reveals that nvcc is indeed not in the specified directory:

[~/NVIDIA_CUDA-9.1_Samples]$ which nvcc
/usr/bin/nvcc
[~/NVIDIA_CUDA-9.1_Samples]$ tree /usr/local/cuda-9.1
/usr/local/cuda-9.1
├── bin
│   └── gcc
│       └── gcc -> /usr/bin/cuda-gcc
├── src
└── targets
    └── x86_64-linux
        ├── include
        │   └── cudnn.h
        └── lib
            ├── libcudnn.so
            ├── libcudnn.so.7
            ├── libcudnn.so.7.0.5
            └── libcudnn_static.a

7 directories, 6 files

It also shows that the source / library files are not present (as they had before when I was using the official install which had some problems with Fedora 27). Soft-linking to /usr/bin/nvcc didn't solve this problem because the source files cannot be found.

Here is my linux information:

[~/NVIDIA_CUDA-9.1_Samples]$ cat /proc/version
Linux version 4.15.10-300.fc27.x86_64 (mockbuild@bkernel02.phx2.fedoraproject.org) (gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)) #1 SMP Thu Mar 15 17:13:04 UTC 2018

I am glad to provide more information if any is required. Thanks!

scaronni commented 6 years ago

Please read the instructions if you plan to use the repository hosted here, especially for CUDA. After installing, you should logout/login to get the environment variables set up correctly.

Also, are you using the CUDA samples from the upstream installer? You can then just install the cuda-samples package and the Makefiles should be corrected already.

scaronni commented 6 years ago

Also, please clean your system from the old CUDA installation, the path /usr/local/cuda-9.1 is not provided by these packages.

kkalavantavanich commented 6 years ago

Thank you for the fast response. I followed the instructions on https://negativo17.org/nvidia-driver/ running:

$ sudo dnf install cuda cuda-devel 

nvcc seems to be installed as I indicated. However, the configuration for the PATH and LIB environment variables (as followed from the old CUDA installation) remains the same and is broken. Please guide me as to where I can find how to set these variables for the new CUDA installation.

Also, I did install the cuda-samples package but I cannot find the location of the samples file. Where are they?

scaronni commented 6 years ago

nvcc seems to be installed as I indicated. However, the configuration for the PATH and LIB environment variables (as followed from the old CUDA installation) remains the same and is broken. Please guide me as to where I can find how to set these variables for the new CUDA installation.

Those are in the /etc/profile.d/cuda.* files, and are sourced in login shells. You don't need to set anything. You just need to make sure there are no leftovers from the previous CUDA installation.

Also, I did install the cuda-samples package but I cannot find the location of the samples file. Where are they?

...ehm.... they are in the package:

rpm -ql cuda-samples

The are in a read only directory, so obviously you need to copy them somewhere writable.

kkalavantavanich commented 6 years ago

You mean that I do not install the samples using dnf install cuda-samples?