log in with googlenvidia怎么建账号

EC2上的深度学习:CUDA 7/cuDNN/caffe/DIGITS实战教程
发表于 08:40|
来源个人博客|
作者Raffael Vogler
摘要:本教程将演示如何在一个g2.2xlarge EC2实例(运行64位Ubuntu14.04)中设置CUDA7、cuDNN、caffe和DIGITS,以及如何快速上手DIGITS。文章通过一个检测糖尿病视网膜病变的Kaggle竞赛案例来说明DIGITS的具体应用。
本教程将演示如何在一个g2.2xlarge EC2实例(运行64位的Ubuntu14.04)中设置CUDA7、cuDNN、caffe和DIGITS,以及如何快速上手DIGITS。为了说明DIGITS的应用,本教程使用一个当前的
Kaggle竞赛项目作为案例进行演示, 是关于糖尿病视网膜病变检测的,其状态来自于荧光血管造影。
图像分类的卷积深度神经网络(DNN)
对于图像的分类或回归,你有两种选择:
特征工程及把图像转换为向量;
依赖于一个卷积DNN求出特征。
深度神经网络对计算的要求相当苛刻。这是由两个原因造成的:
即使你使用一个很小的图像分辨率,输入数据也大得多,256×256的RGB像素意味着196608个输入神经元(256×256×3)。而如果你要使你的特征工程智能一些,那么1000个神经元已经是一个很大的数量了;
让网络有计算出相关特征也需要一个更复杂的网络结构和更多层。
幸运的是,许多浮点矩阵的运算都被显卡的GPU无意中解决。
NVIDIA DIGITS和caffe
利用GPU支持深度学习的主流框架目前有三个,包括Theano、Torch和caffe。 NVIDIA DIGITS则是一个网络服务器,它提供了一个方便的网络接口,用于训练和测试基于caffe的深度神经网络。我打算在以后的文章中涵盖如何使用caffe工作。在这里,我会告诉你如何设置CUDA。
首先你需要一个AWS帐号和g2.2xlarge实例启动和运行,并确保为你的IP的5000端口添加入站规则——这是DIGITS服务器的需要。# don't forget to get your system up to date
sudo apt-get update
sudo apt-get dist-upgrade安装CUDA7
这一步的主要来源是
。# installation of required tools
sudo apt-get install -y gcc g++ gfortran build-essential \
git wget linux-image-generic libopenblas-dev python-dev \
python-pip python-nose python-numpy python-scipy
# downloading the (currently) most recent version of CUDA 7
sudo wget http://developer./compute/cuda/repos/ubuntu/cuda-repo-ubuntu-28_amd64.deb
# installing CUDA
sudo dpkg -i cuda-repo-ubuntu-28_amd64.deb
sudo apt-get update
sudo apt-get install cuda
# setting the environment variables so CUDA will be found
echo -e "\nexport PATH=/usr/local/cuda/bin:$PATH" && .bashrc
echo -e "\nexport LD_LIBRARY_PATH=/usr/local/cuda/lib64" && .bashrc
sudo reboot
# installing the samples and checking the GPU
cuda-install-samples-7.0.sh ~/
cd NVIDIA\_CUDA-7.0\_Samples/1\_Utilities/deviceQuery
./deviceQuery安装cuDNN
要进一步加快深度学习相关的计算,安装cuDNN库是一个好主意。为了这个目的,你将需要注册一个NVIDIA开发者账户,并加入CUDA注册开发者计划。最后一步需要NVIDIA解锁你的帐户,这可能需要一两天。但你也可以在没有cuDNN库的情况下开始。只要你得到他们的允许——
并把它上传到您的实例。# unpack the library
gzip -d cudnn-6.5-linux-x64-v2.tar.gz
tar xf cudnn-6.5-linux-x64-v2.tar
# copy the library files into CUDA's include and lib folders
sudo cp cudnn-6.5-linux-x64-v2/cudnn.h /usr/local/cuda-7.0/include
sudo cp cudnn-6.5-linux-x64-v2/libcudnn* /usr/local/cuda-7.0/lib64安装caffe
caffe及DIGITS的安装步骤主要来源于
。sudo apt-get install libprotobuf-dev libleveldb-dev \
libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev \
libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler \
libatlas-base-dev
# the version number of the required branch might change
# consult /NVIDIA/DIGITS/blob/master/README.md
git clone --branch v0.11.0 /NVIDIA/caffe.git
cd ~/caffe/python
for req in $(cat requirements.txt); do sudo pip install $ done
cd ~/caffe
cp Makefile.config.example Makefile.config
# check that USE_CUDNN is set to 1 in case you would
# like to use it and to 0 if not
make runtest
echo -e "\nexport CAFFE_HOME=/home/ubuntu/caffe" && ~/.bashrc
# load the new environmental variables
bash安装DIGITScd ~
git clone /NVIDIA/DIGITS.git digits
sudo apt-get install graphviz gunicorn
for req in $(cat requirements.txt); do sudo pip install $ done启动和配置DIGITS
DIGITS在第一次启动时会问你一些关于配置目的的问题。这些设置是非常直白,并且可以事后在~/.digits/digits.cfg中更改。你可能要考虑在一个EBS上定位你的工作目录(jobs_dir)——在我的例子中,大约140,000 张PNG图像数据集,消耗大约10 GB的空间,训练模型(含所有的模型快照)约占1 GB。# change into your digits directory
# start the server
./digits-devserverDIGITS故障排除
当你第一次启动DIGITS时,你可能会遇到一些错误和警告。以下是我的情况。"libdc1394 error: Failed to initialize libdc1394"
# no big deal - either ignore or treat symptomatically
sudo ln /dev/null /dev/raw1394"Gtk-WARNING **: Locale not supported by C library."
# not sure how serious this is - but it is easy to resolve
sudo apt-get install language-pack-en-base
sudo dpkg-reconfigure locales
# check what locales are available and then ...
# ... set LC_ALL to it
echo -e "\nexport LC_ALL=\"en_US.utf8\"" && ~/.bashrc"Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed"
# this is a big deal and will cause the server start up to fail:
# connect with ssh flags -Xi
ssh -Xi ..."Couldn't import dot_parser, loading of dot files will not be possible."
# reinstall pyparsing:
sudo pip uninstall pyparsing
sudo pip install pyparsing==1.5.7
sudo pip install pydotDIGITS入门
首先,你必须在想要训练的模型上创建一个数据集。你必须提供至少一个大的图片数据集用于训练并且任选两个较小的数据集进行验证和测试。你可以通过不同的文件夹的意思分离这些数据集(及它们正确的标签),或者通过提供相应的CSV。这些CSV中都应该具有两个未命名的制表符分隔列。第一列保证图像的完整路径(home不要使用~,要使用它的实际路径),第二列保证基于0的索引引用正确的类。你还需要提供一个文本文件持有不同的类别——每行一个。
例如,如果你有两个类“POS”(行1)和“NEG”(行2)——那么一个属于“POS”类的图像必须有与之相关联的类索引0。加载可能需要一段时间。我加载140,000个PNG的256×256分辨率的图像历时约一小时。
设置目标训练模型会很容易,倘若你坚持使用默认建议——你只需要选择要使用的数据集、网络就可以了。在描述的数据集上训练一个30 epochs的
大约花一天又6小时。所以你需要确保以下两点:
对于Spot实例的出价不能太低——否则你会有被终止的风险;
在 session上启动服务器。否则,如果连接中断(也许因为你的IP在一夜之间改变了),服务器进程将会被杀死。
应对糖尿病性视网膜病变的Kaggle挑战
所提供的训练集由约35,000个高分辨率的图像组成——压缩和拆分成五个文件。所有ZIP压缩包大小约33 GB。我用lynx直接下载五个压缩包到一个EBS中——因为你可以定期登录并启动下载。顺便说一下,g2.2xlarge实例的下载速度是令人难以置信——你被授予最高100MB/秒的速度。我同时开始所有的五个下载任务,每个下载任务的速度是6MB/秒。准确地说,是兆字节(mega
byte),而不是兆比特(mega bit——DSL提供商使用的单位)。
糖尿病性视网膜病变的可见指标,按照我的理解主要是泄漏(瘤)和病理上不断增长的血管。我认为,这些特征像具有相似性且旋转不变。因此,为了增加可用训练集我创建了四个版本:
(A):调整为256×256像素并保存为PNG;
(R):(A)的180度旋转;
(A)的垂直镜像;
(R)的垂直镜像。
因为手头的任务显然不是一个分类而是一个回归,我放弃尝试学习一个分类为无DR和DR的四个阶段。我标记所有DR的情况为“积极”,无DR情况为“消极”。这都会被执行于所有四个可能的分割({0}
VS {1,…,4},…,{0,…,3},{4}),这些预测最后会相对实际阶段回归。
这一变换的bash脚本,你都可以在相应的
一方面我本来希望看到一个更高的精度——在另一方面,我勉强可以(如果有的话)做出在一些健康的情况下和在有些极端的第四阶段情况下之间的差异。以73.95%为消极的情况下的比例——这也是网络精度的起点。经过30
epochs,它提高约8个百分点,达到81.8%。
关于DIGITS特性和具体问题,强烈推荐
,在这里你可以和DIGITS的开发者进行有效和开放的交流。
原文链接:
&(编译/王玮 责编/周建丁)
第七届中国云计算大会将于6月3日-5日在北京国家会议中心举办。目前主会演讲嘉宾名单和议题方向已经公布,众多中国科学院/中国工程院院士、BAT云技术领军人、三大运营商云计算负责人、中国银联执行副总裁、青云联合创始人等嘉宾届时都将带来精彩演讲。欢迎大家访问
,了解更多详情。
推荐阅读相关主题:
CSDN官方微信
扫描二维码,向CSDN吐槽
微信号:CSDNnews
相关热门文章Laptops with Nvidia graphics cards using Nvidia Optimus can be configured to render scenes on the discrete Nvidia GPU (Graphics Processing Unit) card using
and copy the rendered scenes to the Intel GPU using XRandR.
Since Nvidia Optimus will be using the integrated Intel graphics for modesetting, the following kernel options will need to be enabled:
KERNEL Linux kernel 4.3.3+Device Drivers
Graphics Support
Direct Rendering Manager (Xfree86 4.1.0 and higher DRI support)
Enable legacy fbdev support for your modesetting driver
&*& Intel 8xx/9xx/G3x/G4x/HD Graphics
Enable preliminary support for prerelease Intel hardware by default
ImportantIn the case that something should go wrong, it is recommended to have live media to assist in reverting any changes. Having a ,
(which is a Gentoo based recovery image), or a
around work nicely for this purpose. If you choose to proceed without having a "just in case" alternative boot method proceed with extreme caution!
Install the X.org driver, OpenGL libraries, XvMC libraries, and VDPAU libraries
Add support for Advanced Configuration and Power Interface
Install non-GLVND libGL for backwards compatibility
Install the kernel driver module
Install nvidia-settings with support for GTK+ 3
Enable support for kernel mode setting (KMS)
On 64bit systems, if you want to be able to compile 32bit and 64bit binaries
PaX patches from the PaX project
Build static versions of dynamic libraries as well
Install additional tools such as nvidia-settings
Install the Unified Memory kernel module (nvidia-uvm) for sharing memory between CPU and GPU in CUDA programs
Enable dev-libs/wayland backend
Installing Nvidia drivers is easy, run the following:
root #emerge --ask x11-drivers/nvidia-drivers
Configuring a system to use Nvidia's proprietary driver is not easy as the installation. There are several configuration files that will need to be modified in order for a system to work properly.
If the user has chosen to not use built-in modules, then the init system should load the necessary modules on system boot. If /proc/config.gz is available, this can verified by running the following command:
user $zgrep "CONFIG_MODULES=" /proc/config.gzCONFIG_MODULES=y
If the output returns CONFIG_MODULES set to N, then the kernel will need recompiled with support to load modules. Information about that can be found over here. After module loading support has been added, return to this article and continue reading.
Create a new file called nvidia.conf in the /etc/modules-load.d directory. It should contain the nvidia module name:
FILE /etc/modules-load.d/nvidia.confnvidia
Verify the modules-load init script has been added to the boot runlevel (it should be by default, but double check):
root #rc-update add modules-load boot
Check the status of the systemd-modules-load.service to verify things are running smoothly. If issues arise this service unit will be the place to check:
root #systemctl start systemd-modules-load.service
The best way to set the system's xorg.conf correctly would be to read the documentation Nvidia has provided. The documentation can be found in a couple of locations. To save time, consider reading only the pages on Optimus and XRandR, as they are vital to correct configuration. If the driver has already been emerged (done in the installation step above), the documentation can be found locally at /usr/share/doc/nvidia-drivers-343.36/README.bz2.
Example: Use the less command to read the local documentation:
user $less /usr/share/doc/nvidia-drivers-343.36/README.bz2
It is also possible to read the documentation at Nvidia's website by following these (external) links:
For a quick example here on the wiki, view .
If X.Org X server version 1.17.2 or higher is installed ()
FILE /etc/X11/xorg.conf.d/20-nvidia.confSection "Module"
Load "modesetting"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "&BusID for NVIDIA device here&"
Option "AllowEmptyInitialConfiguration"
EndSection
It is probably best to first try a simple configuration first like described in the Nvidia driver manual:
ImportantEnsure the currently running kernel has CONFIG_I2C_CHARDEV enabled and the resulting i2c-dev module loaded or compiled monolithically for read-edid to work.
Some laptops/notebooks may benefit from saving the EDID screen information to a file so it can be passed to the Intel modesetting driver. The EDID information can be saved using the read-edid utility.
root #emerge --ask x11-misc/read-edid
root #get-edid & /lib/firmware/edid/_Clevo_W670SR.bin
The EDID information is provided to the Intel GPU (Graphics Processing Unit) by specifying its
location in the kernel boot parameter:
drm_kms_helper.edid_firmware=edid/_clevo_W670SR.bin
If the GRUB2 bootloader is being used, this can be configured in the file /etc/default/grub
FILE /etc/default/grubGRUB_CMDLINE_LINUX_DEFAULT=&drm_kms_helper.edid_firmware=edid/_clevo_W670SR.bin&
GRUB_GFXMODE=
Note: If using Sabayon Linux, the kernel boot parameters should be specified in the /etc/default/sabayon-grub file
instead of /etc/default/grub file.
to view an example xorg.conf using an EDID for a specific monitor.
Per Nvidia's , the following commands are required before starting X:
CODE XRandR commands:xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
This is to say any Display Manager that starts X-Windows then asks the user to log in will result in a black screen unless the above xrandr commands are run before asking the user to log in.
WarningThe xrandr commands must be added to the system's X session start up scripts (such as ~/.xinitrc) in order for the X display to start using modesetting. Failure to do so will result in a black screen.
NOTE: If you get a black screen with no back-lighting from the previous steps, creating .xsessionrc and placing the xinitrc commands in there COULD fix it.
Use the xrandr command to find the appropriate graphics device:
root #xrandr --listproviders
The following shows a list of where to add the required xrandr commands, sorted by desktop.
CONFIG_PROTECT=&/usr/share/sddm/scripts/Xsetup&
root #emerge --ask sys-apps/qingy
Add the xrandr commands to the end of the /etc/X11/Sessions/KDE-4 file:
FILE /etc/X11/Sessions/KDE-4KDE-4's X session filexrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
Add the xrandr commands to the end of the ~/.xsession file.
In the /etc/directfbrc configuration file. It is necessary to set the busid variable to the BusID of the Intel graphics card as reported by the lspci command:
root #lspci
For example, if lspci says the Intel graphics card is on BusID 00:02.0, then add the following line to {{Path}/etc/directfbrc}}
FILE /etc/directfbrcbusid=0:02:0
root #emerge --ask x11-misc/cdm
Add the xrandr commands to ~/.xinitrc file:
root #emerge --ask kde-base/kdm
Add the xrandr commands to the /usr/share/config/kdm/Xsetup file and protect them like described above.
Add the xrandr commands to the /usr/share/sddm/scripts/Xsetup file and protect them like described above.
For Mint Desktop Manager fetch the ebuild and install :
root #emerge --ask gnome-base/mdm
Add the xrandr commands to the /etc/X11/mdm/Init/Default file:
Add the xrandr commands to the /usr/lib/X11/xdm/Xsetup_0 file and protect them like described above.
NOTE: if the system is a 32-bit system, add the commands to the /usr/lib64/X11/xdm/Xsetup_0 file.
If using a 64-bit system, edit the /etc/X11/xdm/xdm-config configuration file and change the following line to point to the Xsetup_0 file created above:
CODE X Display Manager ExampleDisplayManager._0.setup: /usr/lib/X11/xdm/Xsetup_0
For the Gnome Desktop Manager fetch the ebuild and install :
root #emerge --ask gnome-base/gdm
Create two .desktop files:
FILE /etc/xdg/autostart/optimus.desktop & /usr/share/gdm/greeter/autostart/optimus.desktopDesktop Entries[Desktop Entry]
Type=Application
Name=Optimus
Exec=sh -c "xrandr --setprovideroutputsource modesetting NVIDIA-0; xrandr --auto"
NoDisplay=true
X-GNOME-Autostart-Phase=DisplayServer
Make sure that GDM uses X as default backend (this does only affect .
will still use wayland when USE="wayland" is enabled):
FILE /etc/gdm/custom.confcustom.conf# GDM configuration storage
# Uncoment the line below to force the login screen to use Xorg
WaylandEnable=false
[security]
# Uncomment the line below to turn on debugging
#Enable=true
Since there are many files to configure and because the Nvidia's proprietary support for Optimus in Linux is buggy, it is rather easy to create a faulty Optimus configuration. It is possible something was typed incorrectly, or a certain configuration was not compatible with the hardware being used. Whatever the case, a broken configuration means that debugging is required.
To debug, carefully read the logs from dmesg (/var/log/dmesg) and Xorg (/var/log/Xorg.0.log) with a
they are the best indicators to find issues. If something irregular is discovered, make changes to the respective configuration files. Other areas to inspect for debugging include any of the configuration files that were modified through the course of this article (the kernel's {Path|.config}}, kernel boot parameters passed at /etc/default/grub, the Xorg's /etc/X11/xorg.conf file, etc.). Continue checking the files as necessary then reboot the system and try again. Many attempts may be required in order to obtain a working configuration! It is
time could be spent on something more interesting, but if debugging is required in order to get Optimus working then it needs to happen.
To aid in distinguishing between important and unimportant messages in /var/log/dmesg and /var/log/Xorg.0.log files, working examples have been provided at these sub-articles:
- In short, for all the screens to work, set the configuration to discrete mode in the motherboard firmware.
This page was last modified on 4 November 2017, at 19:57.
Gentoo Foundation, Inc.
Gentoo is a trademark of the Gentoo Foundation, Inc.
The contents of this document, unless otherwise expressly stated, are licensed under the

我要回帖

更多关于 log in with nvidia 的文章

 

随机推荐