How to install Theano on Amazon EC2 GPU instances for deep learning

本文提供了一套详细的指南,教你如何在Amazon EC2 GPU实例上安装Theano及其依赖项,以便进行深度学习任务。文章涵盖了创建EC2实例、安装Theano及配置环境等步骤。



3 min read

[update] If you would like to skip the instructions and just install from an AMI, search the community for ami-b141a2f5 (Theano - CUDA 7) in the N. California region.

Theano is an amazing Python package for deep learning that can utilize NVIDIA's CUDA toolkit to run on the gpu. The gpu is orders of magnitude faster than the cpu for math operations (such as matrix multiplication), which is essential for many machine learning algorithms. While setting up AWS to run my thesis experiments, I realized many instructions were out of date. Hopefully these steps will help you get your deep learning models up and running on AWS. These instructions use Ubuntu 14.04 64-bit with Cuda 7.0 on a g2.2xlarge instance.

Creating an EC2 g2.2xlarge instance

Log into your AWS management console and click over to EC2. There are two options for creating your instance:

  • On-Demand Instances: This option guarantees that your have your section of a machine for computing. Use this option if you cannot handle potential interrupts and are willing to pay more. As of this writing, a g2.2xlarge instance costs $0.65/hr. To create a dedicated instance, go to "Instances" and click "Launch Instance".
  • Spot Instances: This option gives you left-over compute power at a much cheaper rate. Use this option if you can hande potential interrupts. Spot instances use a bidding system to determine who gets the left-over compute power; you can look at the history of rates under "Spot Requests". As of this writing, a g2.2xlarge spot instance costs $0.0642/hr (10% of the price!) and seems fairly stable over the last few months. I ended up using a few spot requests, bidding $0.07.

When choosing an AMI to use for the instance, pick the latest 64-bit Ubuntu (I used ami-df6a8b9b, which is Ubuntu 14.04). You should also set up the security group for your IP to have ssh access, and download a new private/public key file.

Installing Theano and its dependencies

Follow the instructions on Amazon to ssh into your instance. For Ubuntu on AWS, I found you have to use :

ssh -i [path/to/key.pem] ubuntu@[DNS]  

Once you ssh into the instance, I recommend using screens (now updated to Tmux) to keep the session open so your program can run without the terminal window being open. Here are all the commands and the order I used to set up Theano:

1) update the default packages

sudo apt-get update

sudo apt-get -y dist-upgrade  

2) create a new screen named theano (or look at using Tmux instead)

screen -S “theano”  

3) install all the dependencies

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  

4) install the bleeding-edge version of Theano

sudo pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git  

5) grab the latest (7.0) cuda toolkit.

sudo wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.0-28_amd64.deb  

6) depackage Cuda

sudo dpkg -i cuda-repo-ubuntu1404_7.0-28_amd64.deb  

7) add the package and install the cuda driver (this takes a while)

sudo apt-get update

sudo apt-get install -y cuda  

8) update the path to include cuda nvcc and ld_library_path

echo -e "\nexport PATH=/usr/local/cuda/bin:$PATH\n\nexport LD_LIBRARY_PATH=/usr/local/cuda/lib64" >> .bashrc  

9) reboot the system for cuda to load

sudo reboot  

Wait a little bit for the reboot and then ssh back into the instance.

10) install included samples and test cuda

cuda-install-samples-7.0.sh ~/

cd NVIDIA\_CUDA-7.0\_Samples/1\_Utilities/deviceQuery  
make  
./deviceQuery

Make sure it shows that the GPU exists.

11) set up the theano config file to use gpu by default

echo -e "\n[global]\nfloatX=float32\ndevice=gpu\n[mode]=FAST_RUN\n\n[nvcc]\nfastmath=True\n\n[cuda]\nroot=/usr/local/cuda" >> ~/.theanorc  

That's it! Now you can use git to pull whatever repo you need and test Theano. I recommend using the test script from Theano's site here.

These instructions were partially gathered from Erik Bernhardsson and Erik Hazzard, as well as the Ubuntu instructions from Theano.

Optimizations

Netflix has a great post showing that you can customize some functions in the Cuda kernel to speed up Theano by ~70%. I haven't done this, but it is definitely something to check out.

转自:http://markus.com/install-theano-on-aws/

这个是完整源码 python实现 Flask,Vue 【python毕业设计】基于Python的Flask+Vue物业管理系统 源码+论文+sql脚本 完整版 数据库是mysql 本文首先实现了基于Python的Flask+Vue物业管理系统技术的发展随后依照传统的软件开发流程,最先为系统挑选适用的言语和软件开发平台,依据需求分析开展控制模块制做和数据库查询构造设计,随后依据系统整体功能模块的设计,制作系统的功能模块图、E-R图。随后,设计框架,依据设计的框架撰写编码,完成系统的每个功能模块。最终,对基本系统开展了检测,包含软件性能测试、单元测试和性能指标。测试结果表明,该系统能够实现所需的功能,运行状况尚可并无明显缺点。本文首先实现了基于Python的Flask+Vue物业管理系统技术的发展随后依照传统的软件开发流程,最先为系统挑选适用的言语和软件开发平台,依据需求分析开展控制模块制做和数据库查询构造设计,随后依据系统整体功能模块的设计,制作系统的功能模块图、E-R图。随后,设计框架,依据设计的框架撰写编码,完成系统的每个功能模块。最终,对基本系统开展了检测,包含软件性能测试、单元测试和性能指标。测试结果表明,该系统能够实现所需的功能,运行状况尚可并无明显缺点。本文首先实现了基于Python的Flask+Vue物业管理系统技术的发展随后依照传统的软件开发流程,最先为系统挑选适用的言语和软件开发平台,依据需求分析开展控制模块制做和数据库查询构造设计,随后依据系统整体功能模块的设计,制作系统的功能模块图、E-R图。随后,设计框架,依据设计的框架撰写编码,完成系统的每个功能模块。最终,对基本系统开展了检测,包含软件性能测试、单元测试和性能指标。测试结果表明,该系统能够实现所需的功能,运行状况尚可并无明显缺点。本文首先实现了基于Python的Flask+Vue物业管理系统技术的发
源码地址: https://pan.quark.cn/s/a4b39357ea24 # SerialAssistant串口助手 下载地址: 本仓库release文件夹 在线下载:http://mculover666.cn/SerialAssistant.zip 功能说明 本项目是使用C# + WinForm框架编写的串口助手。 目前版本为2.0.0版本,拥有以下功能: 未打开串口时,自动扫描可用端口 接收数据支持文本或者HEX方式显示 支持接收数据加入时间戳 支持将当前接收数据保存为文件 支持发送文本数据或HEX数据 支持自动定时发送数据 支持从文件中(.txt, .json)加载数据到发送文本框 支持发送数据记录(不重复记录) ……欢迎加入更多功能 环境说明 VS2019 .NET Framework 4.5 教程 C#上位机开发(一)—— 了解上位机 C#上位机开发(二)—— Hello,World C#上位机开发(三)—— 构建SerialAssistant雏形 C#上位机开发(四)—— SerialAssistant功能完善 C#上位机开发(五)——SerialAssistant界面升级(WinForm界面布局进阶) C#上位机开发(六)——SerialAssistant功能优化(串口自动扫描功能、接收数据保存功能、加载发送文件、发送历史记录、打开浏览器功能、定时发送功能) C#上位机开发(七)—— 修改窗口图标和exe文件图标 C#上位机开发(八)—— 美化界面(给按钮添加背景) 更新日志 2018/6/3 完成串口属性设置,打开与关闭异常处理; 字符串发送功能; 字符串接收功能; 2018/6/4 完善串口扩展功能界面部分 2018/6/6 完善...
基于共轭转移与噬菌体介导的 CRISPR 系统对抗耐药菌的建模研究(Matlab代码实现)内容概要:本文档标题为《基于共轭转移与噬菌体介导的 CRISPR 系统对抗耐药菌的建模研究(Matlab代码实现)》,但实际内容并未围绕该主题展开具体论述,而是列举了大量与Matlab仿真相关的科研技术服务项目,涵盖智能优化算法、机器学习、路径规划、无人机应用、电力系统优化、信号处理等多个领域,并提供了相关资源的网盘下载链接。文档强调科研需逻辑缜密、善于借力与创新,建议按目录顺序阅读以避免迷失方向。真正关于CRISPR系统对抗耐药菌的研究内容缺失,标题与正文严重不符。; 适合人群:具备一定科研基础,熟悉Matlab编程,从事工程优化、生物信息、控制系统、电力系统、人工智能等相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:①获取各类科研问题的Matlab代码实现资源,如优化调度、预测建模、路径规划等;②复现高水平论文中的算法模型;③开展跨学科仿真研究时借鉴技术方案与代码框架;④利用提供的YALMIP等工具包进行优化问题求解。; 阅读建议:注意本文档标题与实际内容不符,重点应放在其所列出的技术服务范围和提供的网盘资源上,使用者可根据自身研究方向筛选相关内容,结合提供的代码实例进行学习与二次开发,同时注意甄别信息的有效性与准确性。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值