迫不及待的想在Ubuntu 16.04 安装 NVIDIA CUDA Toolkit 7.5并安装gromacs5.1.2看这里


NVIDIA CUDA Toolkit 7.5 目前官方只适配了 Ubuntu 15.04 和 Ubuntu 14.04 两个版本的系统。如果你是这两个系统,可以直接去官方下载安装文件安装。

1. 将nouveau显卡驱动加入黑名单

nouveau去驱动是ubuntu自带的驱动,需要将其删除掉才能安装 NVIDIA的驱动

  • 首先新建一个/etc/modprobe.d/blacklist-nouveau.conf文件 输入如下文字
    blacklist nouveau
    options nouveau modeset=0
  • 运行
  • $ sudo update-initramfs -u
  • nouveau放入黑名单
  • 2. 驱动安装文件下载

    从 Nvidia 官网下载 CUDA 7.5 为为 Uubuntu 15.04 适配的 runfile(local)

    cuda_7.5.18_linux.run

    3. 准备工作

    添加必要的依赖

    $sudo apt-get update

    </pre><p></p><p><span style="font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'; widows:1; background-color:rgb(234,239,224)"></span></p><pre name="code" class="plain" style="line-height: 19.6000003814697px; font-size: 13.6px; font-weight: bold; color: rgb(51, 51, 51);">$sudo apt-get install ca-certificates-java default-jre default-jre-headless fonts-dejavu-extra freeglut3 freeglut3-dev java-common libatk-wrapper-java libatk-wrapper-java-jni  libdrm-dev libgl1-mesa-dev libglu1-mesa-dev libgnomevfs2-0 libgnomevfs2-common libice-dev libpthread-stubs0-dev libsctp1 libsm-dev libx11-dev libx11-doc libx11-xcb-dev libxau-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb1-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev libxmu-dev libxmu-headers libxshmfence-dev libxt-dev libxxf86vm-dev lksctp-tools mesa-common-dev x11proto-core-dev x11proto-damage-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-gl-dev x11proto-input-dev x11proto-kb-dev x11proto-xext-dev x11proto-xf86vidmode-dev xorg-sgml-doctools xtrans-dev libgles2-mesa-dev nvidia-modprobe build-essential

    </pre><h1 style="line-height: 19.6000003814697px; font-size: 13.6px; font-weight: bold; color: rgb(51, 51, 51);">4 安装 CUDA</h1><pre name="code" class="plain" style="line-height: 19.6000003814697px; font-size: 13.6px; font-weight: bold; color: rgb(51, 51, 51);">

    $ chmod 755 cuda_7.5.18_linux.run

    </pre><p></p><p><span style="font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'; widows:1; background-color:rgb(234,239,224)"></span></p><pre name="code" class="plain" style="line-height: 19.6000003814697px; font-size: 13.6px; font-weight: bold; color: rgb(51, 51, 51);">$ sudo ./cuda_7.5.18_linux.run --override

    -------------------------------------------------------------

    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 352.39? ((y)es/(n)o/(q)uit): y

    Install the CUDA 7.5 Toolkit? ((y)es/(n)o/(q)uit): y

    Enter Toolkit Location [ default is /usr/local/cuda-7.5 ]:

    Do you want to install a symbolic link at /usr/local/cuda? ((y)es/(n)o/(q)uit): y

    Install the CUDA 7.5 Samples? ((y)es/(n)o/(q)uit): y

    Enter CUDA Samples Location [ default is /home/kinghorn ]: /usr/local/cuda-7.5

    Installing the CUDA Toolkit in /usr/local/cuda-7.5 ...

    Finished copying samples.

    </pre><p></p><p><span style="font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'; widows:1; background-color:rgb(234,239,224)"></span></p><pre name="code" class="plain" style="line-height: 19.6000003814697px; font-size: 13.6px; font-weight: bold; color: rgb(51, 51, 51);">===========

    = Summary =

    ===========

    </pre><p></p><p><span style="font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'; widows:1; background-color:rgb(234,239,224)"></span></p><pre name="code" class="plain" style="line-height: 19.6000003814697px; font-size: 13.6px; font-weight: bold; color: rgb(51, 51, 51);">Driver:   Not Selected

    Toolkit:  Installed in /usr/local/cuda-7.5

    Samples:  Installed in /usr/local/cuda-7.5

    </pre><p></p><h1 style="line-height:1.4; font-weight:bold; color:rgb(51,51,51); margin-top:1em; margin-bottom:16px; font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'; widows:1"><span style="font-size:18px"> 5 配置 CUDA 环境变量</span></h1><p></p><blockquote style="margin:0 0 0 40px; border:none; padding:0px"><p><span style="font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'; widows:1; background-color:rgb(234,239,224)"></span></p><pre name="code" class="plain" style="line-height: 19.6000003814697px; font-size: 13.6px; font-weight: bold; color: rgb(51, 51, 51);">$sudo vi /etc/profile.d/cuda.sh

    里面输入

    export PATH=$PATH:/usr/local/cuda/bin

    export LD_LIBRARY_PATH=$PATH:/usr/local/cuda/lib64

    </pre><p></p><p><span style="font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'; widows:1; background-color:rgb(234,239,224)"></span></p><pre name="code" class="plain" style="line-height: 19.6000003814697px; font-size: 13.6px; font-weight: bold; color: rgb(51, 51, 51);">$ source /etc/profile.d/cuda.sh


    6. 修改 CUDA header 文件使其兼容 gcc 5

    该版本的 CUDA 无法在 gcc > 4.8 时使用,因此我们需要注释掉代码中的 gcc 版本检测代码

    sudo vim /usr/local/cuda/include/host_config.h
    
    line: 115 comment out error
    //#error -- unsupported GNU version! gcc versions later than 4.9 are not supported!  

    6. 编译 gromacs

    下载最新版的 gromacs
     wget ftp://ftp.gromacs.org/pub/gromacs/gromacs-5.1.2.tar.gz
    下载好之后 
    tar xfz gromacs-5.1.2.tar.gz
       cd gromacs-5.1.2

    下面请注意:
    由于 gcc 5 用到的 /usr/include/string.h 相比 gcc 4 中的 string.h 有所改动。如果直接make,你可能会遇到类似这种错误
    /usr/include/string.h: In function ‘void* __mempcpy_inline(void*, const void*, size_t)’: /usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope return (char *) memcpy (__dest, __src, __n) + __n; ^ /usr/include/string.h: In function ‘void* __mempcpy_inline(void*, const void*, size_t)’: /usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope return (char *) memcpy (__dest, __src, __n) + __n; 
    
    解决此问题的方法是:
    找到 /home/chun/gromacs-5.1.2/cmake/gmxManageNvccConfig.cmake
    在218行下面加入 下面红色代码 行
             sudo vi /home/chun/gromacs-5.1.2/cmake/gmxManageNvccConfig.cmake

    list(APPEND GMX_CUDA_NVCC_FLAGS "${GMX_CUDA_NVCC_GENCODE_FLAGS}")

    list(APPEND GMX_CUDA_NVCC_FLAGS "-use_fast_math")

    list(APPEND GMX_CUDA_NVCC_FLAGS "-D_FORCE_INLINES")

    # assemble the CUDA host compiler flags

    # with CMake <2.8.10 the host compiler needs to be set on the nvcc command line

    保存之后

    然后再继续



       mkdir build
       cd build
       cmake .. -DGMX_BUILD_OWN_FFTW=ON -DGMX_GPU=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
       make
       make check
       sudo make install
       source /usr/local/gromacs/bin/GMXRC

    • 现在就可以计算了


    参考文献https://gist.github.com/dangbiao1991/2c895917ea888ce33af8c1c72444b7bf

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好!要在Ubuntu 16.04安装CUDA,您可以按照以下步骤进行操作: 1. 首先,确保您的系统满足CUDA的要求。您可以访问NVIDIA的官方文档来查看支持的操作系统版本和硬件要求。 2. 下载CUDA Toolkit。您可以在NVIDIA的官方网站上找到CUDA Toolkit下载链接。选择适合您系统的版本,并下载相应的.run文件。 3. 在终端中导航到您下载的.run文件所在的目录,并通过以下命令将其设置为可执行文件: ``` chmod +x cuda_*.run ``` 4. 运行.run文件以启动安装程序,通过按照提示进行安装。在安装过程中,您可能需要接受许可协议、选择安装选项和提供管理员密码等。 5. 安装完成后,需要将CUDA的路径添加到系统环境变量中。打开终端并编辑 `~/.bashrc` 文件: ``` nano ~/.bashrc ``` 6. 在文件末尾添加以下行来设置CUDA相关的环境变量: ``` export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH ``` 7. 保存并关闭文件,然后运行以下命令使环境变量生效: ``` source ~/.bashrc ``` 8. 最后,您可以验证CUDA是否成功安装。在终端中运行以下命令来检查CUDA版本: ``` nvcc --version ``` 如果安装成功,您应该能够看到CUDA的版本信息。 这些是在Ubuntu 16.04安装CUDA的基本步骤。请注意,具体的安装过程可能因您的系统配置而有所不同。如果遇到任何问题,建议参考NVIDIA的官方文档或寻求社区支持。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值