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

来源:互联网 发布:天池大数据 经验 编辑:程序博客网 时间:2024/06/05 10:36


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

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

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

  • 首先新建一个/etc/modprobe.d/blacklist-nouveau.conf文件 输入如下文字
    blacklist nouveauoptions 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.hline: 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 0
    原创粉丝点击