7/5 CAFFE实验学习笔记(2)
——SSD(Single Shot MultiBox Detector)
1、ubuntu 查看环境变量
1. Linux查看环境变量显示环境变量HOME
|
2. Linux查看环境变量设置一个新的环境变量hello
|
3. Linux查看环境变量使用env命令显示所有的环境变量
|
2、AttributeError: 'module' object has no attribute 'LabelMap'
ruyunli@ruyunli-All-Series:~/data/VOC0712$./create_data.sh
/home/ruyunli/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py:273:UserWarning: Matplotlib is building the font cache using fc-list. This may takea moment.
warnings.warn('Matplotlib is building the font cache using fc-list. Thismay take a moment.')
Traceback (most recent call last):
File "/home/ruyunli/caffe/caffe/data/VOC0712/../../scripts/create_annoset.py",line 103, in <module>
label_map = caffe_pb2.LabelMap()
AttributeError:'module' object has no attribute 'LabelMap'
Traceback (most recent call last):
File "/home/ruyunli/caffe/caffe/data/VOC0712/../../scripts/create_annoset.py",line 103, in <module>
label_map = caffe_pb2.LabelMap()
AttributeError: 'module'object has no attribute 'LabelMap'
solution:
caffe.protoREADME
# As of Ubuntu14.04 protoc is no longer a part of libprotobuf-dev package and should beinstalled
# separately as in: sudo apt-get install protobuf-compiler
3、ImportError:libcudart.so.7.5: cannot open shared object file: No such file or directory
ruyunli@ruyunli-All-Series:~/data/VOC0712$./create_data.sh
Traceback (most recent call last):
File"/home/ruyunli/caffe/caffe/data/VOC0712/../../scripts/create_annoset.py",line 7, in <module>
from caffe.proto import caffe_pb2
File "/home/ruyunli/caffe/python/caffe/__init__.py", line 1,in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver,AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "/home/ruyunli/caffe/python/caffe/pycaffe.py", line 13,in <module>
from ._caffe import Net, SGDSolver, NesterovSolver,AdaGradSolver, \
ImportError: libcudart.so.7.5: cannot open shared object file: No such file ordirectory
Traceback (most recent call last):
File "/home/ruyunli/caffe/caffe/data/VOC0712/../../scripts/create_annoset.py",line 7, in <module>
from caffe.proto import caffe_pb2
File "/home/ruyunli/caffe/python/caffe/__init__.py", line 1,in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver,AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "/home/ruyunli/caffe/python/caffe/pycaffe.py", line 13,in <module>
from ._caffe import Net, SGDSolver, NesterovSolver,AdaGradSolver, \
ImportError:libcudart.so.7.5: cannot open shared object file: No such file or directory
solution :
1、 安装cuda
Download:cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb (md5sum: 5cf65b8139d70270d9234d5ff4d697c7)
Installation Instructions:
`sudo dpkg -i cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb`
`sudo apt-get update`
`sudo apt-get install cuda`
2、 nvidia-cuda-toolkit
3、 cudnn的安装
f [ -f "cudnn-7.0-linux-x64-v4.0-prod.tgz" ] ; then tar -xvf cudnn-7.0-linux-x64-v4.0-prod.tgz sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64 sudo cp cuda/include/cudnn.h /usr/local/cuda/include fi # Need to put cuda on the linker path. This may not be the best way, but it works. sudo sh -c"sudo echo '/usr/local/cuda/lib64' > /etc/ld.so.conf.d/cuda_hack.conf" sudo ldconfig /usr/local/cuda/lib64 |
注:sudo sh a language interpreter |
4、删除文件夹
mkdir 目录名 => 创建一个目录
rmdir 空目录名 => 删除一个空目录
rm 文件名 文件名 =>删除一个文件或多个文件
rm –rf 非空目录名 => 删除一个非空目录下的一切
touch 文件名 => 创建一个空文件
5、apt-get update & apt-get upgrade
In anutshell, apt-get update doesn't actually install new versions ofsoftware.
- apt-get update downloads the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies. It will do this for all repositories and PPAs. From http://linux.die.net/man/8/apt-get:
Used tore-synchronize the package index files from their sources. The indexes ofavailable packages are fetched from the location(s) specified in /etc/apt/sources.list(5).An update should always be performed before an upgrade or dist-upgrade.
- apt-get upgrade will fetch new versions of packages existing on the machine if APT knows about these new versions by way of apt-get update.
From http://linux.die.net/man/8/apt-get:
Used to installthe newest versions of all packages currently installed on the system from thesources enumerated in /etc/apt/sources.list(5). Packages currentlyinstalled with new versions available are retrieved and upgraded; under nocircumstances are currently installed packages removed, nor are packages thatare not already installed retrieved and installed. New versions ofcurrently installed packages that cannot be upgraded without changing theinstall status of another package will be left at their current version. [Emphasismine] An update must be performed first so that apt-get knows that new versionsof packages are available.
6、安装CUDAMAT
http://www.erogol.com/setting-cudamat-ubuntu-machine/
problem:
ruyunli@ruyunli-All-Series:~/Downloads/cudamat-master$ make
nvcc -O --ptxas-options=-v --compiler-options '-fPIC' -o libcudamat.so --sharedcudamat.cu cudamat_kernels.cu -lcublas
make: nvcc: Command not found
make: *** [cudamat] Error 127
solution:
sudo apt-get install nvidia-cuda-toolkit
7、ImportError: libcudart.so.7.5: cannot open shared object file: Nosuch file or directory
problem:File"/home/ruyunli/caffe/python/caffe/pycaffe.py", line 13, in<module>
from ._caffe import Net, SGDSolver, NesterovSolver,AdaGradSolver, \
ImportError:libcudart.so.7.5: cannotopen shared object file: No such file or directory
Traceback (most recent call last):
solution:
PYTHONPATH=$PYTHONPATH:/path/to/cudamat PYTHONPATH=$PYTHONPATH:/home/ruyunli/Downloads/cudamat-master
export PYTHONPATH(在没有PYTHONPATH的前提下)
8、安装显卡驱动
sudoadd-apt-repository ppa:graphics-drivers/ppa
sudo apt-getupdate
sudo apt-getinstall nvidia-352 nvidia-prime
sudo reboot
$ lspci -vnn |grep -i VGA -A 12
9、检查是否安装显卡驱动
To verify that your GPU is CUDA-capable, goto your distribution's equivalent of System Properties, or, from the commandline, enter:
$ lspci | grep -i nvidia
10、Depends: nvidia-352-uvm (>= 352.93) but it is not going to beinstalled
The followingpackages have unmet dependencies:
cuda-drivers : Depends:nvidia-352-uvm (>=352.93) but it is not going to be installed
Depends: nvidia-352-dev (>= 352.93)but it is not going to be installed
Depends: nvidia-opencl-icd-352 (>=352.93) but it is not going to be installed
Solution:
Sudo apt-get install nvidia-352-uvm 安装即可
sudo apt-getinstall nvidia-cuda-toolkit
11、查看CUDA版本
nvcc –V
12、设置环境变量 $CAFFE_HOME
系统环境变量
系统环境变量一般保存在下面的文件中:
· /etc/environment
· /etc/profile
· /etc/bash.bashrc
/etc/profile和 /etc/bash.bashrc在Ubuntu 10.0版本中不推荐使用。
如想将一个路径加入到$PATH中,可以像下面这样做(修改/etc/profile):
1. sudo vi /etc/profile
在里面加入:
1. JAVA_HOME=/usr/jdk1.6.0_25
2.export JAVA_HOME
3. PATH=$PATH:$JAVA_HOME/bin
4.export PATH
5. CLASSPATH=.:$JAVA_HOME/lib
6.export CLASSPATH
你可以自己加上指定的多个路径,中间用冒号隔开。环境变量更改后,在用户下次登陆时生效,如果想立刻生效,则可执行下面的语句:
1. source /etc/profile
13、python import failed (python import .py file)
Problem | Traceback (most recent call last): File "/home/ruyunli/caffe/caffe/data/VOC0712/../../scripts/create_annoset.py", line 103, in <module> label_map = caffe_pb2.LabelMap() |
Solution | caffe_root='/home/ruyunli/ssdcaffe/' sys.path.insert(0, caffe_root + 'python') |
>>> import sys >>> sys.path(按照顺序) ['', '/home/ruyunli/caffe/python', '/home/ruyunli/anaconda2/lib/python27.zip', '/home/ruyunli/anaconda2/lib/python2.7', '/home/ruyunli/anaconda2/lib/python2.7/plat-linux2', '/home/ruyunli/anaconda2/lib/python2.7/lib-tk', '/home/ruyunli/anaconda2/lib/python2.7/lib-old', '/home/ruyunli/anaconda2/lib/python2.7/lib-dynload', '/home/ruyunli/anaconda2/lib/python2.7/site-packages', '/home/ruyunli/anaconda2/lib/python2.7/site-packages/Sphinx-1.3.5-py2.7.egg', '/home/ruyunli/anaconda2/lib/python2.7/site-packages/setuptools-20.3-py2.7.egg'] Python通过sys.path来寻找import的路径 |
修改PYTHONPATH: PYTHONPATH=/home/ruyunli/ssdcaffe/python:$PYTHONPATH PYTHONPATH自动加入sys.path中 |
14、永久修改PYTHON_PATH
如何将路径“永久"添加到sys.path?
sys.path是python的搜索模块的路径集,是一个list
复制代码代码如下:
['', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\\Python26\\DLLs','C:\\Python26\ \lib', 'C:\\Python26\\lib\\plat-win','C:\\Python26\\lib\\lib-tk', 'C:\\Python26 ','C:\\Python26\\lib\\site-packages', 'C:\\Python26\\lib\\site-packages\\win32' ,'C:\\Python26\\lib\\site-packages\\win32\\lib', 'C:\\Python26\\lib\\site-packages\\Pythonwin']
可以在python 环境下使用sys.path.append(path)添加相关的路径,但在退出python环境后自己添加的路径就会自动消失!
在python脚本中修改
复制代码代码如下:
import sys
sys.path.append('c:\\mypythonlib')
为解决这个问题,可以有以下方法:
1. 将自己做的py文件放到 site_packages 目录下:
下面命令显示了 site-packages 目录:
复制代码代码如下:
python -c "from distutils.sysconfig import get_python_lib; printget_python_lib() "
但是这样做会导致一个问题,即各类模块都放到此文件夹的话,会导致乱的问题,这一点是显而易见的。
注意,也不创建子文件夹,再将自己的模块放到子文件夹解决问题,这会导致使用import 语句时错误。
2. 使用pth文件,在 site-packages 文件中创建 .pth文件,将模块的路径写进去,一行一个路径,以下是一个示例,pth文件也可以使用注释:
# .pth file for the my project(这行是注释)
E:\DjangoWord
E:\DjangoWord\mysite
E:\DjangoWord\mysite\polls
这个不失为一个好的方法,但存在管理上的问题,而且不能在不同的python版本中共享。
3. 使用PYTHONPATH环境变量,在这个环境变量中输入相关的路径,不同的路径之间用逗号(英文的!)分开,如果PYTHONPATH 变量还不存在,可以创建它!
路径会自动加入到sys.path中,而且可以在不同的python版本中共享,应该是一样较为方便的方法。
关于与python相关的环境变量有那些,请参考:
http://docs.python.org/using/cmdline.html
在页面上找到PYTHONPATH
4、vim ~/.bashrc
$PYTHONPATH=/RAID/ruyun.li/caffe/python:$PYTHONPATH
source ~/.bashrc
15、CUDA driver version is insufficient for CUDA runtime &
error == cudaSuccess(30 vs. 0) unknown error
Solution:
Terminal Method Assume the file is called some-app.run and is in the folder /home/user/Downloads. You will need to modify these instructions to fit your situation. 1. Open a terminal (Applications->Accessories->Terminal). 2. enter cd /home/user/Downloads 3. enter chmod +x some-app.run 4. enter ./some-app.run 5. if step 4 fails with a message including 'permission denied', try entering sudo ./some-app.run(you will need to enter your password for this). |
http://www.binarytides.com/install-nvidia-drivers-ubuntu-14-04/ The xorg-edgers ppa provides the very latest nvidia drivers. Run the following commands to set it up. $ sudo add-apt-repository ppa:xorg-edgers/ppa -y $ sudo apt-get update # 331 driver $ sudo apt-get install nvidia-331
# 334 driver $ sudo apt-get install nvidia-334
# install the latest version $ sudo apt-get install nvidia-current |