0------ Arrange the gcc compiler in the early stage, otherwise the following manual installation of python will report an error:
Method 1:
This method is super simple:
sudo apt-get build-depgcc
can be done with the above command
Method 2:
sudo apt-get install build-essential
is still simple, one command can also be done
after installation, you can execute
gcc--version
The command to check the version, the output is as follows:
gcc(GCC)4.2.3(Ubuntu4.2.3-2ubuntu7)
Copyright(C)2007FreeSoftwareFoundation,Inc.
Method 3:
1. Download the GCC source code :
wget ftp://mirrors.kernel.org/gnu/gcc/gcc-4.9.0/gcc-4.9.0.tar.gz
Or download the corresponding version directly from the following official website
2. Unzip:
tar -zxvf gcc-4.9.0.tar.gz
3. Download the dependencies required for compilation:
cd gcc-4.9.0 //Enter the unpacked gcc folder
./contrib/download_prerequisites //Download dependencies
cd .. //return to the upper directory
4. Create a compilation output directory:
mkdir gcc-build-4.9.0
5. Enter the output directory, execute the following command, and generate the makefile:
cd gcc-build-4.9.0 ../gcc-4.9.0/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
6. Compile:
make -j4
The next step is to wait, the whole process takes about 40 minutes. PS: It is best not to do anything else during the compilation process. The CPU is fully loaded during the whole process. If it is terminated inexplicably, there will be a lot of trouble later.
7. Installation:
After compiling, we can execute the installation :
make install
8. Check the version:
gcc --version or gcc -v
1------ Use manual installation of python3.5
Method:1. Find the download address on the official python website and get the address of Python-3.5.1.tgz
2. wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz to download the installation package
3. tar -zxvf Python-3.5.1.tgz decompress the installation package4. cd Python-3.5.1
5. ./configure (if an error is reported: configure: error: no acceptable C compiler found in $PATH, it means that gcc is not installed, Need to install sudo apt-get install gcc)
6. make (if the make command is not installed, you need to install sudo apt-get install make)
7. make test
8. sudo make install
安装成功,可以测试看看,直接输入python3
十、安装pip:
sudo apt-get install python3-pip
十一、解决python无法使用退格、dele问题:(后来发现是我使用的远程连接工具SecureCRT有问题,还有python问题)
直接敲入python,命令交互式,无法使用退格键、方向键
解决办法一:
手动安装:
sudo apt-get install libncurses5-dev
下载:
https://pypi.python.org/packages/source/r/readline/readline-6.2.4.1.tar.gz#md5=578237939c81fdbc2c8334d168b17907
pypi地址:https://pypi.python.org/pypi/readline
tar -xvf readline-6.2.4.1.tar.gz
cd readline-6.2.4.1
python setup.py install
解决办法二:
最快捷的方式:
pip install readline
其他注意事项:
还有其他说法,可能需要安装
sudo apt-get install libreadline6 libreadline6-dev
最终:
在安装完readline-devel之后,在pthon3.5的安装目录
使用make && make install //重新编译&&安装python
再次运行python3.5的时候,上下左右键就可以正常进行左右移动了
另外推荐一个命令行python编辑神器:
pip install ipython
如果尝试不行,请更换root用户后再进行安装。
2. 安装NVIDIA驱动
打开terminal输入以下指令:
sudo apt-get update
- 1
然后在系统设置->软件更新->附加驱动->选择nvidia最新驱动(361)->应用更改
3-------下载cuda8.0(我下载的是gpu的版本),具体的安装步骤已经在下图中圈出,我们只要按照步骤安装就行了。
安装完毕后,再声明一下环境变量,并将其写入到 ~/.bashrc 的尾部:
export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
检查 CUDA Toolkit是否安装成功
终端输入 :(如果结果如下,说明cuda安装成功)
nvcc -V
nvidia-smi
gcc降版本
ubuntu的gcc编译器是5.4.0,然而cuda8.0不支持5.0以上的编译器,因此需要降级,把编译器版本降到4.9:
在terminal中执行:
sudo apt-get install g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
4---------下载cudnn--需要注册下信息,然后才选择下载。注意:要对应cuda的版本下载。
如果要使用gpu来对tensorflow进行加速,除了安装CUDA以外,cuDNN也是必须要安装的。跟cuda一样,去nvidia的官网下载cuDNN的安装包。不过这次没法直接下载,需要先注册,然后还要做个调查问卷什么的,稍微有点麻烦。我下的是cuDNN v5.1 Library for Linux
这个版本。不要下cuDNN v5.1 Developer Library for Ubuntu16.04 Power8 (Deb)
这个版本,因为是给powe8处理器用的,不是amd64.
下载下来以后,发现是一个tgz的压缩包,使用tar进行解压
tar -xvf cudnn-8.0-linux-x64-v5.1.tgz
- 1
安装cuDNN比较简单,解压后把相应的文件拷贝到对应的CUDA目录下即可
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
4--------下载tensorflow ,我下载gpu版本https://pypi.python.org/pypi/tensorflow-gpu/1.4.0
下载下来后,安装命令如下:
sudo -H pip3 install --upgrade tensorflow_gpu-1.4.0-cp35-cp35m-manylinux1_x86_64.whl
安装成功后,每次使用 TensorFlow 的时候需要激活 conda 环境,可以看到,在正常情况下,是anaconda的bin路径在环境变量中,但激活conda-tensorflow环境后,环境变量中存储的是tensorflow下的bin路径
测试tensorflow是否安装成功
(1) 激活conda环境
(2)进入python
(3)import tensorflow
整个过程比较顺利,tensorflow被成功import了