其中其决定作用的是这篇文章  https://www.pugetsystems.com/labs/hpc/Install-TensorFlow-with-GPU-Support-the-Easy-Way-on-Ubuntu-18-04-without-installing-CUDA-1170/

注意兼容版本:https://devtalk.nvidia.com/default/topic/1047898/cuda-setup-and-installation/cuda-10-1-tensorflow-1-13/2

1. 安装显卡驱动

在终端执行如下命令,建议先切换到国内源,如huaweicloud mirrors。

sudo apt purge nvidia*
ubuntu-drivers devices            # 可以看到显卡等设备,和推荐的驱动
sudo ubuntu-drivers autoinstall   # 安装推荐驱动,通常是最新版

如果通过ubuntu-drivers devices看不到NVidia显卡,则添加

sudo add-apt-repository ppa:graphics-drivers
sudo apt-get update

安装完后,重启系统, 启动后,在图形界面运行Nvidia X Server Settings,可以看到显卡情况,如下图。

2. 安装Anaconda+Tensorflow-GPU

安装 Anaconda

bash Anaconda3-5.3.0-Linux-x86_64.sh # make sure append the Anaconda executable directory to your PATH environment variable in .bashrc
source ~/.bashrc
python --version # to show the python version

装之前,推荐切换到国内源:

anaconda的源改为国内镜像, 配置文件是~/.condarc

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes

pip源改为国内镜像, 配置文件是~/.pip/pip.conf, 该后的文件内容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host=https://pypi.tuna.tsinghua.edu.cn

update conda

conda update conda -y
conda update anaconda -y
conda update python -y
conda update --all -y

安装tensorflow

conda create --name tf-gpu   # Create a Python "virtual environment" for TensorFlow using conda
conda activate tf-gpu       # 注意运行此命令后,命令行开头的提示变为(tf-gpu) user@computer:~$,表示tf-gpu环境处于激活状态
# 后面的命令,都在tf-gpu环境下执行,我保留了命令行的提示,以示区别
(tf-gpu) user@computer:~$ conda install tensorflow-gpu -y # install TensorFlow with GPU acceleration and all of the dependencies.

为Tensorflow环境创建Jupyter Notebook Kernel

(tf-gpu) user@computer:~$ conda install ipykernel -y
(tf-gpu) user@computer:~$ conda install jupyter
(tf-gpu) user@computer:~$ python -m ipykernel install --user --name tf-gpu --display-name "TensorFlow-GPU"

安装keras

(tf-gpu) user@computer:~$ conda install keras -y

3. 测试安装结果

用Keras 例程(Keras内部会用到Tensorflow)

打开Jupyter Notebook

jupyter notebook

创建新笔记: New下拉菜单 -> 选择TensorFlow-GPU

输入如下测试代码,并运行:

# Import dependencies
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.layers import Flatten,  MaxPooling2D, Conv2D
from keras.callbacks import TensorBoard# Load and process the MNIST data
# 推荐先下载mnist.npz到目录~/.keras/datasets/
(X_train,y_train), (X_test, y_test) = mnist.load_data(path="mnist.npz")
X_train = X_train.reshape(60000,28,28,1).astype('float32')
X_test = X_test.reshape(10000,28,28,1).astype('float32')
X_train /= 255
X_test /= 255
n_classes = 10
y_train = keras.utils.to_categorical(y_train, n_classes)
y_test = keras.utils.to_categorical(y_test, n_classes)# Create the LeNet-5 neural network architecture
model = Sequential()
model.add(Conv2D(32, kernel_size=(3,3), activation='relu', input_shape=(28,28,1)) )
model.add(Conv2D(64, kernel_size=(3,3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(n_classes, activation='softmax')) # Compile the model
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) # Set log data to feed to TensorBoard for visual analysis
tensor_board = TensorBoard('./logs/LeNet-MNIST-1') # Train the model
model.fit(X_train, y_train, batch_size=128, epochs=15, verbose=1,validation_data=(X_test,y_test), callbacks=[tensor_board])

运行完后查看误差曲线

 (tf-gpu) dbk@i9:~$ tensorboard --logdir=./logs --port 6006

效果如下图

Ubuntu 18.04+NVidia显卡+Anaconda3+Tensorflow-GPU安装、配置、测试(无需手动安装CUDA)相关推荐

  1. Ubuntu 16.04 + Nvidia 显卡驱动 + Cuda 8.0 (问题总结 + 解决方案)

    Ubuntu 16.04 + Nvidia 显卡驱动 + Cuda 8.0 (问题总结 + 解决方案) 安装Nvidia驱动出现的问题 问题主要是三种,(1)循环登录,也就是登录之后在退出来到登录界面 ...

  2. Ubuntu 14.04 Nvidia显卡驱动安装及设置

    原文地址为: Ubuntu 14.04 Nvidia显卡驱动安装及设置 更换主板修复grub 引导后,无法从Nvidia进入系统(光标闪烁), 可能是显卡驱动出了问题. 1. 进入BIOS设置, 从集 ...

  3. 基于Ubuntu 18.04机器人操作系统环境和深度学习环境配置

    基于Ubuntu 18.04机器人操作系统环境和深度学习环境配置详解 CUDA+Cudnn+ROS+anaconda+ubuntu装机必备 笔记本双系统安装 U盘启动项安装ubuntu18.04.1 ...

  4. Win 10 + Ubuntu 18.04 双系统安装与深度学习环境配置安装踩坑实录(上篇)

    Win 10 + Ubuntu 18.04 双系统安装与深度学习环境配置安装踩坑实录(上篇) 折腾了两三天总算顺利在电脑上完成了装x的双系统安装,一路走来还比较顺利,主要在ubuntu的显卡设置上躺了 ...

  5. Ubuntu 18.04上进行HyperLedger Fabric 1.2.0环境及链码安装、部署和测试

    Ubuntu 18.04上进行HyperLedger Fabric 1.2.0环境及链码安装.部署和测试 1.环境安装 HyperLedger Fabric 1.2.0环境的安装推荐一篇博客:http ...

  6. 非命令行linux安装zip,如何在Ubuntu 18.04 Bionic Beaver Linux上使用命令行从ZIP文件安装Gnome Shell Extensions...

    目的 目的是在Ubuntu 18.04 Bionic Beaver Linux上使用命令行从ZIP文件安装Gnome Shell Extensions.使用命令行从ZIP文件安装Gnome Shell ...

  7. Ubuntu 18.04双系统,含GPU、Linux Docker、Vitis-AI、休眠省电、五笔,以及安装问题USB启动、左右手错位、cudnn bug、Tweak tool

    参考文献 Windows10安装ubuntu18.04双系统教程 - 不妨不妨,来日方长 - 博客园 https://www.cnblogs.com/masbay/p/11627727.html 下载 ...

  8. Ubuntu 18.04 NVIDIA驱动安装总结

    最近遇到了在Ubuntu 18.04上安装NVIDIA的情况,看到一篇英文教程讲解的很好,简单翻译一下拿来收藏. 在Ubuntu 18.04上安装NVIDIA有三种方法: 使用标准Ubuntu仓库进行 ...

  9. nvidia linux屏幕管理,Ubuntu 11.04 + NVIDIA显卡开启双屏显示

    一直以来超爱双屏,Windows下可以直接按快捷键就可以的,不过Ubuntu下不能快捷键的. 平台:Ubuntu 11.04 + 显卡 NVIDIA 前提:你首先要安装显卡驱动的. 方法:系统 -&g ...

最新文章

  1. 交换机VLAN划分详细手册
  2. mysql外键引用语法_mysql – 外键语法
  3. 扁平化c语言教程,中国象棋人机博弈程序(扁平化棋局) C语言实现
  4. vue2.0 实现导航守卫(路由守卫)
  5. C# 处理图像三种方法对比
  6. NVIDIA更新驱动之后,NVIDIA控制面板消失不见的解决办法
  7. Pentaho BIServer 5.0.1-ce 资源库迁移到 Mysql
  8. Intellij IDEA 设置字体的大小
  9. 浪曦_Struts2应用开发系列_第2讲.Struts2的类型转换-学习笔记
  10. python求一个数的因子_0是素数吗(python求一个数的因子)
  11. Excel 快捷键大全
  12. 3d游戏建模学习心得,自学maya,zbrush,substance一个月的感想
  13. STM32F103移植FreeRTOS必须搞明白的系列知识---1(Cortex-CM3中断优先级)
  14. 《最强大脑:魔方墙找茬王郑才千的学神秘笈-郑才千》-读书笔记
  15. Element UI 组件库分析和二次开发(一)
  16. html无法获取图片高宽,如何解决谷歌浏览器下jquery无法获取图片的尺寸
  17. Nexus Repository Manager 3 远程命令执行漏洞(CVE-2020-10204),CVE-2020-11444 越权漏洞
  18. 美少年为“苹果”编程挣钱 12岁办软件开发公司
  19. 为什么手机网速太慢_为什么手机网速很慢;为什么手机信号满格,网速却很慢?...
  20. 最全的卫星影像分辨率和传感器参数汇总SPOT、IKONOS、QB、北京一号、ZY-1-02C

热门文章

  1. Spring BeanFactory与FactoryBean的区别及其各自的详细介绍于用法
  2. CORD重构边缘DC 开源社区推动多项研究将落地
  3. 《Effective Java》读书笔记--创建和销毁对象
  4. Tempdb数据库详细介绍
  5. 搭建PHP环境遇到的问题!!
  6. 理解oracle中连接和会话
  7. 为什么分散刷新没有死时间_分散项目为何失败(以及如何处理)
  8. 海思涵科技WIFI认证服务器不在线,在海思平台外加一个usb wifi模块,mt7601 加载ok,配置网络ok,但不能ping通?...
  9. linux指令 2>1 到底是个啥
  10. (C++)1037 在霍格沃茨找零钱的两种解法