注意:python3.6和Pytorch v1是安装 fastai v1的最低要求:https://github.com/fastai/fastai/blob/master/README.md#installation

升级python 3.5 至 3.6需要重装python,pip,numpy,需要安装 python3.6-dev。否则安装bottleneck时会报错

1,安装好显卡驱动、CUDA:https://blog.csdn.net/qxqxqzzz/article/details/102794226

2,升级python 3.5 至 3.6 (相当麻烦)

注意环境变量PYTHONPATH的配置!

# 卸载之前的安装
$ sudo pip3 uninstall Bottleneck
$ sudo pip3 uninstall fastai# 升级python 3.5 至 3.6,参考:https://blog.csdn.net/u013749068/article/details/84102749
# 添加源, -E 利用环境变量env
$ sudo -E add-apt-repository ppa:deadsnakes/ppa
# 更新
$ sudo apt-get update
# 安装
$ sudo apt-get install python3.6
# 移除原3.4link
$ sudo rm /usr/bin/python3
# 更换默认python3 的版本为3.6
$ sudo ln -s /usr/bin/python3.6 /usr/bin/python3# 修改环境变量 PYTHONPATH
$ vi ~/.bashrc
# 把 export PYTHONPATH=/usr/bin/python3:/usr/local/lib:/home/xxx/.local/lib/python3.5/site-packages
改成
export PYTHONPATH=/usr/bin/python3:/usr/local/lib
# 注意:一定不要简单地把 3.5改成 3.6,否则会有兼容性问题!!以前在3.5下面安装的包都会找不到了,因为默认搜索3.6的包所在路径!!!!!!!!!!!!!!!!!!# 生效
$ source ~/.bashrc# 安装完Python后pip需重新安装:
$ wget https://bootstrap.pypa.io/get-pip.py  --no-check-certificate
$ python3 get-pip.py --trusted-host=pypi.org --user
# 查看pip位置
$ whereis pip
pip: /usr/local/bin/pip2.7 /usr/local/bin/pip3.5 /usr/local/bin/pip /home/xxx/.local/bin/pip /home/xxx/.local/bin/pip3.6
# 查看pip3位置
$ which pip3
/home/xxx/.local/bin/pip3# 验证
$ pip3 --version
pip 19.3.1 from /home/xxx/.local/lib/python3.6/site-packages/pip (python 3.6)# 更新 pip
$ pip3 --trusted-host=pypi.org --trusted-host=files.pythonhosted.org --trusted-host=download.pytorch.org install --upgrade pip --user
# 更新 setuptools
$ pip3 --trusted-host=pypi.org --trusted-host=files.pythonhosted.org --trusted-host=download.pytorch.org install --upgrade setuptools --user# 卸载numpy
$ sudo pip3 uninstall numpy
# 重装numpy,否则安装bottleneck会报错
$ pip3 --trusted-host=pypi.org --trusted-host=files.pythonhosted.org --trusted-host=download.pytorch.org install numpy --user
# 安装 python3.6-dev,否则安装bottleneck会报错
$ sudo apt-get install python3.6-dev# 验证python和pip
$ python3
Python 3.6.9 (default, Jul  3 2019, 15:36:16)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.$ pip -V
pip 19.3.1 from /home/xxx/.local/lib/python3.6/site-packages/pip (python 3.6)

3,安装pytorch

可以参考:https://blog.csdn.net/qxqxqzzz/article/details/102796522,如果之前安装过,这里python升级之后可能需要再次安装。原版本的pytoch安装在python3.5的site-packages目录下,这里安装的在python3.6的site-packages目录

# 安装或重新安装torch, torchvision,否则 from fastai.utils import * 时会报 ModuleNotFoundError: No module named 'xxx 的错误
$ pip3 --trusted-host=pypi.org --trusted-host=files.pythonhosted.org --trusted-host=download.pytorch.org install torch torchvision --user

4,安装fastai

# 安装bottleneck
$ pip3 --trusted-host=pypi.org --trusted-host=files.pythonhosted.org --trusted-host=download.pytorch.org install Bottleneck --user# 安装fastai
$ pip3 --trusted-host=pypi.org --trusted-host=files.pythonhosted.org --trusted-host=download.pytorch.org install fastai --user# 安装或重新安装以下依赖包:yaml, matplotlib, pandas,否则 from fastai.utils import * 时会报 ModuleNotFoundError: No module named 'xxx 的错误
$ pip3 --trusted-host=pypi.org --trusted-host=files.pythonhosted.org --trusted-host=download.pytorch.org install pyyaml matplotlib pandas --user

5,测试fastai,参考:https://blog.csdn.net/qxqxqzzz/article/details/91769784

-------------------------------------------报错-------------------------------------------------------------

Collecting Bottleneck
  Downloading https://files.pythonhosted.org/packages/05/ae/cedf5323f398ab4e4ff92d6c431a3e1c6a186f9b41ab3e8258dff786a290/Bottleneck-1.2.1.tar.gz (105kB)
     |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒| 112kB 323kB/s
Requirement already satisfied: numpy in ./.local/lib/python3.6/site-packages (from Bottleneck) (1.17.3)
Building wheels for collected packages: Bottleneck
  Building wheel for Bottleneck (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ei9o86zo/Bottleneck/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ei9o86zo/Bottleneck/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-w5v90h2w --python-tag cp36
       cwd: /tmp/pip-install-ei9o86zo/Bottleneck/
  Complete output (43 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/bottleneck
  copying bottleneck/__init__.py -> build/lib.linux-x86_64-3.6/bottleneck
  copying bottleneck/version.py -> build/lib.linux-x86_64-3.6/bottleneck
  creating build/lib.linux-x86_64-3.6/bottleneck/benchmark
  copying bottleneck/benchmark/bench.py -> build/lib.linux-x86_64-3.6/bottleneck/benchmark
  copying bottleneck/benchmark/__init__.py -> build/lib.linux-x86_64-3.6/bottleneck/benchmark
  copying bottleneck/benchmark/autotimeit.py -> build/lib.linux-x86_64-3.6/bottleneck/benchmark
  copying bottleneck/benchmark/bench_detailed.py -> build/lib.linux-x86_64-3.6/bottleneck/benchmark
  creating build/lib.linux-x86_64-3.6/bottleneck/tests
  copying bottleneck/tests/move_test.py -> build/lib.linux-x86_64-3.6/bottleneck/tests
  copying bottleneck/tests/__init__.py -> build/lib.linux-x86_64-3.6/bottleneck/tests
  copying bottleneck/tests/input_modifcation_test.py -> build/lib.linux-x86_64-3.6/bottleneck/tests
  copying bottleneck/tests/nonreduce_axis_test.py -> build/lib.linux-x86_64-3.6/bottleneck/tests
  copying bottleneck/tests/nonreduce_test.py -> build/lib.linux-x86_64-3.6/bottleneck/tests
  copying bottleneck/tests/reduce_test.py -> build/lib.linux-x86_64-3.6/bottleneck/tests
  copying bottleneck/tests/scalar_input_test.py -> build/lib.linux-x86_64-3.6/bottleneck/tests
  copying bottleneck/tests/util.py -> build/lib.linux-x86_64-3.6/bottleneck/tests
  copying bottleneck/tests/list_input_test.py -> build/lib.linux-x86_64-3.6/bottleneck/tests
  creating build/lib.linux-x86_64-3.6/bottleneck/src
  copying bottleneck/src/__init__.py -> build/lib.linux-x86_64-3.6/bottleneck/src
  copying bottleneck/src/template.py -> build/lib.linux-x86_64-3.6/bottleneck/src
  creating build/lib.linux-x86_64-3.6/bottleneck/slow
  copying bottleneck/slow/reduce.py -> build/lib.linux-x86_64-3.6/bottleneck/slow
  copying bottleneck/slow/nonreduce.py -> build/lib.linux-x86_64-3.6/bottleneck/slow
  copying bottleneck/slow/__init__.py -> build/lib.linux-x86_64-3.6/bottleneck/slow
  copying bottleneck/slow/nonreduce_axis.py -> build/lib.linux-x86_64-3.6/bottleneck/slow
  copying bottleneck/slow/move.py -> build/lib.linux-x86_64-3.6/bottleneck/slow
  copying bottleneck/LICENSE -> build/lib.linux-x86_64-3.6/bottleneck
  running build_ext
  building 'bottleneck.reduce' extension
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/bottleneck
  creating build/temp.linux-x86_64-3.6/bottleneck/src
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/xxx/.local/lib/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -c bottleneck/src/reduce.c -o build/temp.linux-x86_64-3.6/bottleneck/src/reduce.o -O2
  In file included from bottleneck/src/reduce.c:1:0:
  bottleneck/src/bottleneck.h:4:20: fatal error: Python.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for Bottleneck
  Running setup.py clean for Bottleneck
Failed to build Bottleneck
Installing collected packages: Bottleneck
    Running setup.py install for Bottleneck ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ei9o86zo/Bottleneck/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ei9o86zo/Bottleneck/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-gphv0q6a/install-record.txt --single-version-externally-managed --compile --user --prefix=
         cwd: /tmp/pip-install-ei9o86zo/Bottleneck/
    Complete output (13 lines):
    running install
    running build
    running build_py
    running build_ext
    building 'bottleneck.reduce' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/bottleneck
    creating build/temp.linux-x86_64-3.6/bottleneck/src
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/xxx/.local/lib/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -c bottleneck/src/reduce.c -o build/temp.linux-x86_64-3.6/bottleneck/src/reduce.o -O2
    In file included from bottleneck/src/reduce.c:1:0:
    bottleneck/src/bottleneck.h:4:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ei9o86zo/Bottleneck/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ei9o86zo/Bottleneck/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-gphv0q6a/install-record.txt --single-version-externally-managed --compile --user --prefix= Check the logs for full command output.

解决:需要安装 python3.6-dev

参考:https://stackoverflow.com/questions/21530577/fatal-error-python-h-no-such-file-or-directory

Linux Ubuntu16.04 Python3.5.2 Cuda10.1 TITAN XP安装fastai v1相关推荐

  1. python3.8.3下载不了nltk_在ubuntu16.04+python3.5情况下安装nltk,以及gensim时pip3安装不成功的解决办法...

    在ubuntu16.04+python3.5情况下安装nltk,以及gensim时pip3安装不成功的解决办法,我刚开始因为不太会用linux命令,所以一直依赖于python 的pip命令,可是怎么都 ...

  2. Ubuntu16.04+GTX1060mq(驱动版本430.64)安装CUDA10.0

    Ubuntu16.04+GTX1060mq(驱动版本430.64)安装CUDA10.0 CUDA下载 cuda最新版本下载地址(可在该页面进入历史版本下载): https://developer.nv ...

  3. Ubuntu16.04(GTX1660ti)cuda10.0和cudnn7.6环境配置 (环境乃一生之敌!!!)

    Ubuntu16.04(GTX1660ti)cuda10.0和cudnn7.6环境配置 (环境乃一生之敌!!!) 第一项:安装显卡驱动 1.下载显卡驱动,到https://www.nvidia.com ...

  4. Win7下使用U盘安装linux Ubuntu16.04双系统图文教程

    Win7下使用U盘安装linux Ubuntu16.04双系统图文教程 Ubuntu(友帮拓.优般图.乌班图)是一个以桌面应用为主的开源GNU/Linux操作系统,Ubuntu 是基于DebianGN ...

  5. 海思Hi3519AV100深度学习方案(一)darknet转caffmodel之caffe安装(基于Ubuntu16.04+python3.5+opencv3.4.0+cuda10.0)

    系列文章目录 海思Hi3519AV100深度学习方案(二)darknet转caffmodel之模型转换(yolov3+caffe+python3.5) 文章目录 系列文章目录 前言 一.系统已有环境检 ...

  6. tensorflow gpu python3.5_tensorflow环境搭建:Ubuntu16.04+python3.5+cuda8.0+tensorflow1.4

    Ubuntu16.04是深度学习主流的操作系统,兼容性也最好. python3.5能够安装支持tensorflow的gpu cuda是nvidia推出的运算平台,cuda8.0对tensorflow比 ...

  7. 百度云服务器BCC安装ubuntu16.04 +python3.6配置uWSGI和Nginx 部署Django项目

    题外话 最近也不开学不开工,闲着没事在做一个python+Django的项目.正好域名之前刚审核通过.开始着手在百度云部署自己的项目,记录一下过程中踩过的坑. 简介 Django是一个功能强大的Web ...

  8. Linux ubuntu16.04 安装opencv4教程(源码编译)

    参考文章1:Ubuntu 安装 OpenCV(亲测有效) 参考文章2:OpenCV - Linux(Ubuntu 16.04)中安装OpenCV + OpenCV_Contrib 参考文章3:ubun ...

  9. linux ubuntu16.04 编译opencv教程(没编过,有时间再弄,推流不用opencv也行的)

    文章目录 下源码 编译 配置opencv环境 下源码 https://github.com/opencv/opencv/releases/tag/4.4.0 然后在ubuntu里建个文件夹把它扔进去, ...

  10. mongodb安装教程Linux,Ubuntu16.04手动安装MongoDB的详细教程

    我最近在研究MongoDB的路上,那么今天也算个学习笔记吧!今天用Ubuntu16.04手动安装MongoDB,分享给大家 注意事项: 仔细按步骤阅读操作 注意别写错字 牢记上面两点 一.用自带的火狐 ...

最新文章

  1. R创建哑变量(Dummy Variables)
  2. 咏南LINUX中间件
  3. matlab内将数组内所有数累乘,数学实验上机汇总【未完成】
  4. 订阅基础:RSS、ATOM、FEED、聚合、供稿、合烧与订阅
  5. java 多线程两种方式_JAVA多线程实现的两种方式
  6. 通过原码、反码、补码彻底搞清左移、右移、无符号右移
  7. 《中国人工智能学会通讯》——6.7 实体链接任务及系统
  8. 常见 CentOS 7 安装问题
  9. PHP实现当前文件夹下所有文件和文件夹的遍历
  10. python蟒蛇实例
  11. Go-Kit实现莫斯电码转换
  12. pxe无盘服务器教程,[教程]Synology+PXE挂载iSCSI网络无盘启动Win7(08.04更新)
  13. 硬核图解面试最怕的红黑树【建议反复摩擦】
  14. 《守望先锋》架构设计与网络同步 -- GDC2017 精品分享实录
  15. 优秀宝宝都有的6个特点
  16. DFS判断回路及回路个数
  17. NCCL无root权限编译安装
  18. SpringBoot整合Mybatis-Plus
  19. 阿里云物联网是什么?
  20. 研报实现——抓“妖股”就那么容易吗?

热门文章

  1. Android游戏添加游戏动画,Android游戏中的动画制作
  2. CTGU 2021春-MySQL数据库实验2:基本查询3-4关,共7小题全代码+信息表+通关截图!
  3. WiFi遥控小车(四):简单直流电机驱动及UDP通信程序
  4. 国外cpa广告联盟EMU-lead-cpa联盟详解(2)im搭建
  5. “联盟鱼”-国外广告联盟lead项目最新玩法介绍
  6. linux下安装weblogic出现的两个错误解决办法
  7. Mini CFA 考试练习题 Ethics and Investment Professionalism
  8. python爬取海量PPT模板,再也不用辛苦地找模板了
  9. C语言如何打印扑克牌花色(红桃、梅花、黑桃、方片)
  10. PKM个人知识管理整理(一)