所以我有三个安装程序用于NVIDIA的CUDA API - 第一个是驱动程序,并带有很好的静默安装标志选项(但你必须是root并且必须运行3级)。
后面的第二个以下显示在下面手动安装(为了简洁起见,删除了长时间安装后的混乱)
[root] #sh cudatoolkit_4.1.28_linux_64_rhel5.x.run验证存档 诚信......一切都好。解压缩NVIDIA CUDA ................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ............................................... .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .......................................
输入安装路径(默认为/ usr / local / cuda,' / cuda'将是 附加):
在/ usr / local / cuda / bin中找到了以前版本的CUDA 你想卸载吗? (是/否/中止):是的
换句话说,我需要认识到: "输入安装路径"并输出' \ n'
现在棘手的部分是卸载可能并不总是存在。如果不是,我只需要等待安装完成,但如果我看到"您要卸载吗?"我需要输出"是"完成。
第三个也是最后一个安装程序的输出如下所示....
[root] #sh gpucomputingsdk_4.1.28_linux.run
验证存档 诚信......一切都好。
解压缩NVIDIA GPU计算
SDK ......................................... .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .............................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .....
输入安装路径(默认为〜/ NVIDIA_GPU_Computing_SDK): / usr / local / CUDA_SDK
位于/ usr / local / cuda的CUDA如果 这是正确的,请选择下面的默认值。
如果不正确, 输入正确的CUDA路径
输入CUDA安装路径 (默认/ usr / local / cuda):
对于这个,没有卸载操作,所以它看起来有点简单。
我只需要检测"输入安装路径"并输出" / usr / local / CUDA_SDK \ n"然后检测"输入CUDA安装路径"并输出" \ n"
我的想法是使用一对expect脚本 - 每个安装程序一个 - 但是由于在命令的双引号内嵌套切换到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"
这会正确切换到root(输入密码后)并正确安装带有内置选项的驱动程序。然后它似乎产生第二个安装过程并输入第一个参数(回车),但似乎提前退出第二个安装程序(例如,我没有看到&#34;是&#34;选项。)。
我觉得我非常接近,希望有人可以指出我出错的地方并提出正确的语法。
备注:
我添加了yum install命令,因为我安装的一些机器没有预料到(库存CentOS 6
),所以这样可以省去我的麻烦....
答案 0 :(得分:3)
这可能是超时问题...不确定安装程序需要多长时间 默认的预期超时为10秒,如果它在那段时间内看不到预期的文本,它将继续,无论如何,您可以像这样更改超时值:
expect -timeout 100 $INSTALL_PATH_REQUEST
同时从
更改$ YESYES="\"Yes\""
要:
YES="\"Yes\r\""
(最好在$ CR中使用\ r而不是\ n)
在安装结束时期待一些“安全字符串”也是一个好主意,例如:
expect -timeout 320 "Install Complete."
因此,在生成的进程完成之前,expect脚本不会终止。