Ubuntu 17.10安裝 CUDA Toolkit 9.0 遇到錯誤“Toolkit: Installation Failed. Using unsupported Compiler.”
『Toolkit: Installation Failed. Using unsupported Compiler.』
這是Ubuntu 17.10正在安裝CUDA Toolkit 9.0的時候跳出來的錯誤訊息…而且幾乎是回答完所有問題的瞬間!
但幾乎可以確定在Ubuntu 16.04 LTS上安裝CUDA Toolkit 9.0是不會遇到這個問題。
原因就是Ubuntu 16.04 LTS的gcc, g++皆6.x版,剛好就是CUDA Toolkit 9.0編譯時所使用的那個版本,所以不會跳出這個錯誤唷!
環境說明:Ubuntu 17.10
gcc:7.x
g++:7.x
原因就是CUDA Toolkit 9.0是用gcc 6.x版製作而成的,如果gcc版本不符這會造成安裝終止!
安裝gcc-6, g++6
安裝相關套件:gcc-6, g++-6
1 |
[andy@Ubuntu ~]$ sudo apt-get install gcc-6 g++-6 |
變更gcc, g++系統連結(捷徑)
看下列第3行,系統預設就是把gcc連結到gcc-7。這個部分必須要手動把連結改掉!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[andy@Ubuntu ~]$ cd /usr/bin/ [andy@Ubuntu bin]$ ls -al gcc* lrwxrwxrwx 1 root root 5 九 18 2017 gcc -> gcc-7 lrwxrwxrwx 1 root root 22 十 10 20:29 gcc-6 -> x86_64-linux-gnu-gcc-6 lrwxrwxrwx 1 root root 22 二 3 09:20 gcc-7 -> x86_64-linux-gnu-gcc-7 lrwxrwxrwx 1 root root 8 九 18 2017 gcc-ar -> gcc-ar-7 lrwxrwxrwx 1 root root 25 十 10 20:29 gcc-ar-6 -> x86_64-linux-gnu-gcc-ar-6 lrwxrwxrwx 1 root root 25 二 3 09:20 gcc-ar-7 -> x86_64-linux-gnu-gcc-ar-7 lrwxrwxrwx 1 root root 8 九 18 2017 gcc-nm -> gcc-nm-7 lrwxrwxrwx 1 root root 25 十 10 20:29 gcc-nm-6 -> x86_64-linux-gnu-gcc-nm-6 lrwxrwxrwx 1 root root 25 二 3 09:20 gcc-nm-7 -> x86_64-linux-gnu-gcc-nm-7 lrwxrwxrwx 1 root root 12 九 18 2017 gcc-ranlib -> gcc-ranlib-7 lrwxrwxrwx 1 root root 29 十 10 20:29 gcc-ranlib-6 -> x86_64-linux-gnu-gcc-ranlib-6 lrwxrwxrwx 1 root root 29 二 3 09:20 gcc-ranlib-7 -> x86_64-linux-gnu-gcc-ranlib-7 |
為了要讓gcc指令指定使用gcc-6的版本!
『ln -sf 』強迫製作軟性捷徑,可以強迫修改已存在的捷徑
1 |
[andy@Ubuntu bin]$ sudo ln -sf gcc-6 gcc |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[andy@Ubuntu bin]$ ls -al gcc* lrwxrwxrwx 1 root root 14 三 22 14:35 gcc -> gcc-6 lrwxrwxrwx 1 root root 22 十 10 20:29 gcc-6 -> x86_64-linux-gnu-gcc-6 lrwxrwxrwx 1 root root 22 二 3 09:20 gcc-7 -> x86_64-linux-gnu-gcc-7 lrwxrwxrwx 1 root root 8 九 18 2017 gcc-ar -> gcc-ar-7 lrwxrwxrwx 1 root root 25 十 10 20:29 gcc-ar-6 -> x86_64-linux-gnu-gcc-ar-6 lrwxrwxrwx 1 root root 25 二 3 09:20 gcc-ar-7 -> x86_64-linux-gnu-gcc-ar-7 lrwxrwxrwx 1 root root 8 九 18 2017 gcc-nm -> gcc-nm-7 lrwxrwxrwx 1 root root 25 十 10 20:29 gcc-nm-6 -> x86_64-linux-gnu-gcc-nm-6 lrwxrwxrwx 1 root root 25 二 3 09:20 gcc-nm-7 -> x86_64-linux-gnu-gcc-nm-7 lrwxrwxrwx 1 root root 12 九 18 2017 gcc-ranlib -> gcc-ranlib-7 lrwxrwxrwx 1 root root 29 十 10 20:29 gcc-ranlib-6 -> x86_64-linux-gnu-gcc-ranlib-6 lrwxrwxrwx 1 root root 29 二 3 09:20 gcc-ranlib-7 -> x86_64-linux-gnu-gcc-ranlib-7 |
測試一下gcc
1 2 3 4 5 6 7 8 |
[andy@Ubuntu bin]$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.4.0-8ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 6.4.0 20171010 (Ubuntu 6.4.0-8ubuntu1) |
改變g++系統連結
做法跟gcc一樣
1 2 3 4 |
[andy@Ubuntu bin]$ ls -al g++* lrwxrwxrwx 1 root root 5 九 18 2017 g++ -> g++-7 lrwxrwxrwx 1 root root 22 十 10 20:29 g++-6 -> x86_64-linux-gnu-g++-6 lrwxrwxrwx 1 root root 22 二 3 09:20 g++-7 -> x86_64-linux-gnu-g++-7 |
1 |
[andy@Ubuntu bin]$ sudo ln -sf g++-6 g++ |
1 2 3 4 |
[andy@Ubuntu bin]$ ls -al g++* lrwxrwxrwx 1 root root 14 三 22 14:37 g++ -> /usr/bin/g++-6 lrwxrwxrwx 1 root root 22 十 10 20:29 g++-6 -> x86_64-linux-gnu-g++-6 lrwxrwxrwx 1 root root 22 二 3 09:20 g++-7 -> x86_64-linux-gnu-g++-7 |
開始安裝CUDA Toolkit 9.0
1 2 |
[andy@Ubuntu ~]$ sudo chmod +x cuda_9.0.176_384.81_linux-run [andy@Ubuntu ~]$ sudo ./cuda_9.0.176_384.81_linux-run --override |
安裝過程會跳出以下幾個詢問對話:
- End User License Agreement:看完或想結束,請按下Q跳出
接下來,安裝程式會問你是否同意:
Do you accept the previously read EULA?
accept/decline/quit: accept -
You are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: y -
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
(y)es/(n)o/(q)uit: n -
Install the CUDA 9.0 Toolkit?
(y)es/(n)o/(q)uit: y -
Enter Toolkit Location
[ default is /usr/local/cuda-9.0 ]: <<按下Enter>> -
/usr/local/cuda-9.0 is not writable.
Do you wish to run the installation with ‘sudo’?
(y)es/(n)o: y
Please enter your password: <<輸入密碼>> -
Please enter your password:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y -
這一步會問你是否要安裝CUDA的範例檔,這就看自己需求了!
Install the CUDA 9.0 Samples?
(y)es/(n)o/(q)uit: y
選則安裝CUDA範例檔的話,就要選擇範例檔的安裝路徑~預設值是家目錄
Enter CUDA Samples Location
[ default is /home/andy ]: <<按下Enter>>
到這裡,CUDA Toolkit應該要安裝成功唷!
將系統設定復原
把系統連結(捷徑)改回去gcc->gcc-7 g++->g++-7
1 2 3 |
[andy@Ubuntu ~]$ cd /usr/bin [andy@Ubuntu bin]$ sudo ln -sf gcc-7 gcc [andy@Ubuntu bin]$ sudo ln -sf g++-7 g++ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[andy@Ubuntu bin]$ ls -al gcc* lrwxrwxrwx 1 root root 5 三 22 15:32 gcc -> gcc-7 lrwxrwxrwx 1 root root 22 十 10 20:29 gcc-6 -> x86_64-linux-gnu-gcc-6 lrwxrwxrwx 1 root root 22 二 3 09:20 gcc-7 -> x86_64-linux-gnu-gcc-7 lrwxrwxrwx 1 root root 8 九 18 2017 gcc-ar -> gcc-ar-7 lrwxrwxrwx 1 root root 25 十 10 20:29 gcc-ar-6 -> x86_64-linux-gnu-gcc-ar-6 lrwxrwxrwx 1 root root 25 二 3 09:20 gcc-ar-7 -> x86_64-linux-gnu-gcc-ar-7 lrwxrwxrwx 1 root root 8 九 18 2017 gcc-nm -> gcc-nm-7 lrwxrwxrwx 1 root root 25 十 10 20:29 gcc-nm-6 -> x86_64-linux-gnu-gcc-nm-6 lrwxrwxrwx 1 root root 25 二 3 09:20 gcc-nm-7 -> x86_64-linux-gnu-gcc-nm-7 lrwxrwxrwx 1 root root 12 九 18 2017 gcc-ranlib -> gcc-ranlib-7 lrwxrwxrwx 1 root root 29 十 10 20:29 gcc-ranlib-6 -> x86_64-linux-gnu-gcc-ranlib-6 lrwxrwxrwx 1 root root 29 二 3 09:20 gcc-ranlib-7 -> x86_64-linux-gnu-gcc-ranlib-7 [andy@Ubuntu bin]$ ls -al g++* lrwxrwxrwx 1 root root 5 三 22 15:32 g++ -> g++-7 lrwxrwxrwx 1 root root 22 十 10 20:29 g++-6 -> x86_64-linux-gnu-g++-6 lrwxrwxrwx 1 root root 22 二 3 09:20 g++-7 -> x86_64-linux-gnu-g++-7 |
幫CUDA Toolkit使用符合版本的gcc, g++
分別建立gcc-6、g++-6的捷徑到CUDA Toolkit的bin目錄之下
1 2 |
[andy@Ubuntu ~]$ sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc [andy@Ubuntu ~]$ sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++ |
測試
測試CUDA是否正確安裝!
1 2 3 |
[andy@Ubuntu ~]$ cd ~/NVIDIA_CUDA-9.0_Samples/5_Simulations/smokeParticles/ [andy@Ubuntu smokeParticles]$ make [andy@Ubuntu smokeParticles]$ ./smokeParticles |
Pingback:使用 Ubuntu 作為 深度學習/機器學習/人工智慧之 平台 - BrilliantCode.net