因此,我有三個用於NVIDIA CUDA API的安裝程序 - 第一個是驅動程序,並帶有很好的靜默安裝標誌選項(但必須是root用戶並且必須具有運行級別3)。在Bash腳本中格式化用戶命令內的腳本
後兩個後續手動如下所示安裝(切出事後安裝出於簡潔的長亂七八糟)
[根]#SH cudatoolkit_4.1.28_linux_64_rhel5.x.run驗證歸檔 完整性.. 。 都好。解壓NVIDIA CUDA .............................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ............................................... .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ..........................................
輸入安裝路徑(默認爲/ usr/local/cuda,'/ cuda'將爲 追加):
CUDA的早期版本位於/ usr/local/cuda/bin
要卸載嗎? (是/否/中止):是
換句話說,我需要認識到: 「進入安裝路徑」,並輸出一個「\ n」
現在棘手的問題是卸載可能不永遠在那裏。如果不是,我只需等待安裝完成,但是如果我看到「您想卸載嗎?」我需要輸出「是」才能完成。
下面的第三個也是最後的安裝程序的輸出顯示....
[根]#SH gpucomputingsdk_4.1.28_linux.run
驗證存檔 完整性...都不錯。
解壓NVIDIA GPU計算
SDK ......................................... .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ..................................
輸入安裝路徑(默認〜/ NVIDIA_GPU_Computing_SDK): /usr/local/CUDA_SDK
位於CUDA位於/ usr/local/cuda
如果 這是正確的,請選擇下面的默認值。
如果它是不正確的, 輸入正確的路徑,CUDA
回車CUDA安裝路徑 (默認是/ usr /本地/ CUDA):
對於這一個,沒有卸載動作所以它看似有點簡單。
我只需要檢測「進入安裝路徑」輸出「在/ usr /本地/ CUDA_SDK \ n」,然後檢測「進入CUDA安裝路徑」輸出「\ n」
我的想法是使用一對期望腳本 - 每個安裝程序都有一個 - 但由於在切換到root的命令的雙引號內嵌套,我遇到了一些困難。我目前擁有的是:
#!/bin/bash
CR="\"\n\""
YES="\"Yes\""
INSTALL_PATH_REQUEST="\"Enter install path\""
CUDA_PATH_REQUEST="\"Enter CUDA install path\""
UNINSTALL_REQUEST="\"Would you like to uninstall?\""
TOOLKIT=`ls -t cudatoolkit* | head -n 1`
TOOLKIT_EXPECT="sh $TOOLKIT"
SDK=`ls -t gpucomputingsdk* | head -n 1`
SDK_INSTALL_PATH="\"/usr/local/CUDA_SDK\n\""
SDK_EXPECT="sh $SDK"
/bin/su root -c "yum -q -y install expect expectk;
/sbin/init 3; sh `ls -t NVIDIA*|head -n 1` -s --update -a -X;
/usr/bin/expect <<EOF;
spawn $TOOLKIT_EXPECT
expect $INSTALL_PATH_REQUEST
send $CR
expect $UNINSTALL_REQUEST
send $YES
EOF
/usr/bin/expect <<EOF;
spawn $SDK_EXPECT
expect $INSTALL_PATH_REQUEST
send $SDK_INSTALL_PATH
expect $CUDA_PATH_REQUEST
send $CR
EOF
/sbin/init 5"
這個切換到正確的根(一旦輸入密碼),並與內置的選項正確安裝驅動程序。然後,它似乎產生第二個安裝過程並輸入第一個參數(回車),但似乎過早退出第二個安裝程序(例如,我看不到「是」選項)。
我覺得我非常接近,希望有人能指出我要去哪裏錯誤,並建議正確的語法。
注: 我加入了百勝安裝命令,如一些我安裝在機器沒有想到(股票CentOS 6
),這樣節省了我的麻煩有....
請不要多發帖子 - http://superuser.com/q/412259/4714 – 2012-04-14 10:48:01