下载 Anaconda3,PyCharm,NVIDIA GeForce GTX 1080Ti 显卡驱动,CUDA,cuDNN,Pytorch 安装包,保存到同一个目录(如“下载”目录)
https://www.anaconda.com/distribution/ 选择 Linux Python 3.7 version 64-Bit (x86) Installer,如下图:
https://www.jetbrains.com/pycharm/download/#section=linux 选择 Community 版,如下图:
https://www.geforce.cn/drivers 按以下条件筛选: 一般选列表第一个: 点击下载按钮:
https://developer.nvidia.com/cuda-90-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=runfilelocal 按以下条筛选并下载:
https://developer.nvidia.com/rdp/cuDNN-archive 下载这个要向注册一个NVIDIA 开发者账号,微信扫码就行。 按以下条件筛选并下载:
两个 whl 包:
https://download.pytorch.org/whl/cu92/torch-1.3.0%2Bcu92-cp37-cp37m-linux_x86_64.whl
https://download.pytorch.org/whl/cu92/torchvision-0.4.1%2Bcu92-cp37-cp37m-linux_x86_64.whl
如果要安装其他版本,自行到 https://download.pytorch.org/whl/torch_stable.html 下载。
由于此次配置的机器默认已关闭这两个选项,跳过。
重启后,先不要直接登录,必须先进入TTY关闭图形界面装好显卡驱动后才能正常进入系统。 CTRL + ALT + F1,打开TTY,输入用户名,密码,关闭图形界面。
sudo service lightdm stop sudo service systemctl stop注意执行文件后面的参数 –dkms --no-opengl-files ,一定要输对! 安装包执行后,会提示 pre-script failed ,不用理会,继续安装,安装过程中: dkms 选 no 32位兼容 选 yes x-org 选 no
输入 yes ,执行安装,安装时各个目录默认即可。
在文件管理器 下载 里面找到安装文件,如 pycharm-community-2019.2.3.tar.gz,右键提取。
打开提取出的文件夹(如 pycharm-community-2019.2.3 ),进入其中的 bin 文件夹,右键 打开终端 ,执行以下命令:
sudo sh ./pycharm.sh然后一直下一步就行,创建快捷方式选 是 。
打开安装好的 Pycharm ,依次进入 File -> Settings -> Project *** -> Project Interpreter , 右边小齿轮,Add -> System Interpreter ,右边三个点,选择 Anaconda3 目录下的 python 解释器( ~/anaconda3/bin/python/python)。
提示是否安装显卡驱动时,选 no (因为之前已经安装了 NVIDIA 显卡驱动,所以这里就不用重复安装,不要问为什么要提前安装好显卡驱动,问就是必须要这样,再问锤人)。
解压 包文件 mmdetection-master.zip ,在解压后的文件夹下打开终端,执行以下命令:
python setup.py develop然后将解压后得到的 mmdet 文件夹复制到Python包文件夹(Python主目录/Lib/site-packages/)下。
打开 Pycharm ,Run -> Edit configurations -> Environment variables,添加以下内容:
LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64/下载预训练模型(本例中为 faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth ): https://github.com/open-mmlab/mmdetection/blob/master/MODEL_ZOO.md 在 Pycharm 中新建一个项目文件夹和一个测试py文件,输入以下内容:
# coding=utf-8 from mmdet.apis import init_detector from mmdet.apis import inference_detector from mmdet.apis import show_result # 模型配置文件 config_file = '../../configs/faster_rcnn_r50_fpn_1x.py' # 预训练模型文件 checkpoint_file = '../../checkpoints/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth' # 通过模型配置文件与预训练文件构建模型 model = init_detector(config_file, checkpoint_file, device='cuda:0') # 测试单张图片并进行展示 img = 'test1.jpg' result = inference_detector(model, img) show_result(img, result, model.CLASSES) # 测试一个图像列表并保存结果图像 imgs = ['test1.jpg', 'test2.jpg', 'test3.jpg'] for i, result in enumerate(inference_detector(model, imgs)): show_result(imgs[i], result, model.CLASSES, out_file='result_{}.jpg'.format(i))运行py文件,执行成功则表示配置成功。 如在配置过程中有任何疑问,欢迎留言! 2019.11.01 23:49 Hafowi