ubuntu14.04-开发环境搭建


一、环境设置

设置不待机不黑屏:右上角system settings->Brightness&Lock->Lock设置为OFF,Turn screen off when inactive for:改为never


二、基础工具安装

为了可以用secureCRT进行登录,我们首先安装openssh-server和lrzsz,还有我比较习惯使用的vim:

sudo apt-get install openssh-server

sudo apt-get install lrzsz 

sudo apt-get install vim


三、更新显卡驱动

1、首先查显卡类型,我是在京东买的,包装箱里也没有显卡的家族信息,所以问的售后,我的显卡是:NVIDIA GeForce 730 2GB GDDR3;

2、如果是uefi的主版,请关掉secure boot。启动按F2进BIOS,选择boot选项卡,disable掉secure boot;

3、到NVIDIA官网找到适合的驱动,并下载:

ubuntu14.04-开发环境搭建_第1张图片

3、卸载原驱动

sudo apt-get install mesa-utils
glxinfo | grep rendering   可以看到输出:direct rendering: Yes

检查nouveau是否存在,应该是存在的:lsmod | grep nouveau

禁用nouveau模块:sudo vim /etc/modprobe.d/blacklist.conf  添加模块黑名单:blacklist nouveau

重启电脑:sudo reboot

检查nouveau是否存在,已经不存在了(而且此时电脑字体变大了):lsmod | grep nouveau


如果还存在,可以直接将这个内核模块挪走,命令为:

find /lib/modules -name "*nouveau*"
sudo mv /lib/modules/$(uname -r)/kernel/drivers/gpu/drm/nouveau/nouveau.ko /lib/modules/$(uname -r)/kernel/drivers/gpu/drm/nouveau/nouveau.ko.bak
重载引导:sudo update-initramfs -u

重启后检查nouveau是否卸载成功:lsmod | grep nouveau

到这应该看不到nouveau了,如果还存在,想办法卸载干净。


4、执行驱动安装

sudo ./NVIDIA-Linux-x86_64-375.26.run -no-x-check -no-nouveau-check -no-opengl-files

–no-x-check 安装驱动时关闭X服务
–no-nouveau-check 安装驱动时禁用nouveau
–no-opengl-files 只安装驱动文件,不安装OpenGL文件

一定要加后面的参数,否则会有循环登录的问题;


安装出现问题,可以执行下面命令卸载:

sudo ./NVIDIA-Linux-x86_64-375.26.run --uninstall


其他卸载方法:

sudo apt-get remove --purge nvidia-*
sudo apt-get install ubuntu-desktop
sudo rm /etc/X11/xorg.conf


5、检查是否成功

命令行输入:nvidia-,按tab可以调出许多命令,已经安装成功。重启电脑(此时电脑字体又恢复了正常)

命令行输入:执行nvidia-settings,可以看到能够正确识别显卡型号:GeForce GT 730

ubuntu14.04-开发环境搭建_第2张图片


四、安装cuda

cuda官网:https://developer.nvidia.com/cuda-downloads

下载安装脚本:wget https://developer.nvidia.com/compute/cuda/8.0/prod/local_installers/cuda_8.0.44_linux-run

安装cuda:

chmod a+x cuda_8.0.44_linux-run

sudo ./cuda_8.0.44_linux-run 


安装选项,注意此时不需要再安driver了:
Do you accept the previously read EULA?
accept/decline/quit:           accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48?
(y)es/(n)o/(q)uit: n

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

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

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

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

Enter CUDA Samples Location
 [ default is /home/yangkai04 ]: /home/yangkai04/local/cuda/


检查是否安装成功:ls /usr/local/cuda-8.0/


五、初始化环境

#!/bin/bash
#
# Copyright, Inc. All Rights Reserved
#
# Author: yangkai04
# Date: 2016/12/26
# Brief:
#   A frame for running applications.
# Globals:
#   none
# Arguments:
#   -h  print help message
# Returns:
#   succ:0
#   fail:1

#set -x # set -o xtrace
#set -e # set -o errexit
#set -u # set -o nounset
set -o pipefail 

TRACK="./track.log"
#rm -f ${TRACK}

function print_help() {
    echo -e "Usage: $0" >&2
    echo -e "    -h  print help message" >&2
    return 0
}

function get_option() {
    while getopts sohvc:t: OPTION; do
        case "${OPTION}" in
            h) print_help
            exit 0
            ;;
            *) print_help
            exit 1
            ;;
        esac
    done
    return 0
}

function init_track() {
    TRACK="./track.log"
    if [[ ! -z "${TRACK}" ]]; then
        touch ${TRACK}
    fi
    return 0
}

function check_track() {
    local FN_STR=$1
    if [[ ! -z "${TRACK}" && -f ${TRACK} ]]; then
        grep "${FN_STR}" ${TRACK}
        if [[ $? -eq 0 ]]; then
            return 1
        else
            return 0
        fi
    fi
    return 0
}

# 1 press u disk to computer, reboot computer and press F12
# 2 restart computer
# 3 connet to the network
function step_network() {
}
function step_source() {
        sudo rm -rf /var/lib/apt/lists/* && \ 
        sudo mkdir /var/lib/apt/lists/partial && \
        sudo apt-get update  
}
function step_profile() {
        BASH_PROFILE=~/.bash_profile
        if [[ ! -f "${BASH_PROFILE}" ]]; then
                touch ${BASH_PROFILE}
                echo -e "if [ -f ~/.bashrc ]; then\n. ~/.bashrc\nfi\n" > ${BASH_PROFILE}
                echo -e "if [ -f ~/.bash_order ]; then\n. ~/.bash_order\nfi\n" >> ${BASH_PROFILE}
                echo -e 'export PATH=$PATH:~/bin\n' >> ${BASH_PROFILE}
        fi
        echo "source ${BASH_PROFILE}"
}

function step_tools() {
        sudo apt-get install vim && \
        sudo apt-get install openssh-server && \
        sudo apt-get install lrzsz && \
        sudo ps -e | grep ssh
}

function step_libs() {
        sudo apt-get install autoconf automake libtool curl make g++ unzip
        sudo apt-get install libgflags-dev 
        sudo apt-get install libgoogle-glog-dev
        sudo apt-get install libgtest-dev

        sudo apt-get install libeigen3-dev
        sudo apt-get install libflann-dev
}

##! @TODO: 运行所有处理函数
##! @AUTHOR: yangkai04
##! @OUT: 0 => success; other => failed
function run_all_step() {
    echo "${FUNCNAME} start."
    ALL_STEPS="
        step_network
        step_source
        step_profile
        step_tools
        step_libs
        "

    local FN_ALL_STEPS=${ALL_STEPS}
    for step in ${FN_ALL_STEPS}; do
        STEP_START_TIME=`date +"%Y-%m-%d %H:%M:%S"`
        STEP_START_TIME_SEC=`date +"%s"`
        local FN_TRACK_MSG="${step}"
        check_track "${FN_TRACK_MSG}"
        if [[ $? -ne 0 ]]; then
            echo "${FN_TRACK_MSG} already run, not to run again."
            continue
        fi
        echo "${step} start."
        ${step}
        if [[ $? -ne 0 ]]; then
            echo "${FN_TRACK_MSG} run error."
            exit 1
        else
            echo -e "${FN_TRACK_MSG}" >> ${TRACK}
        fi
        local FN_END_TIME_SEC=`date +"%s"`
        local FN_RUN_TIME=`expr ${FN_END_TIME_SEC} - ${STEP_START_TIME_SEC}`
        echo "${step} finished. run time[${FN_RUN_TIME}]"
    done
    echo "${FUNCNAME} finished."
    return 0
}

##! @TODO: 程序入口.
##! @AUTHOR: yangkai04
##! @OUT: 0 => success; other => failed
function frame_main() {
    get_option "$@"
    echo "PROGRAM BEGIN."
    run_all_step
    echo "PROGRAM END."
    return 0
}

frame_main "$@"
exit $?




你可能感兴趣的:(ubuntu14.04-开发环境搭建)