Coding Theano under remote ubuntu server from local mac (on local Mac machine, write, run, debug, see-Theano code on remote Ubuntu)

Source: Internet
Author: User
Tags theano

I am a wonderful, recently tinker a set on the MAC coding remote Ubuntu on the Theano code of East, in order to benefit posterity.

Overview: It's my programming environment and network environment

I expect to be able to write, run, debug, view matplotlib images of remote Ubuntu Theano Server on the local Mac machine.

Mac settings (see here )

Given the local debugging of some of the Code on Mac, I've set up a scientific computing environment for my Mac as well.

1.1 Python

When you install Xcode on your Mac, it comes with a lot of things, and Python is one of them. But the Python version provided by Mac is not high, and the syntax differs from standard Python. I installed brewed python with brew.

First install homebrew. Follow their instructions, then come back here.

# Set up some taps and update brew open the hidden Science library and Python Library brew tap homebrew  for scientific toolsbrew tap homebrew/&& Brew Upgrade

# Install a brewed python

Brew Install python

The brew installs everything under the/usr/local/, such as Bin Lib. View brew python with which under/usr/local/bin, the Mac comes with Python under/usr/bin,/usr/local/bin should appear in front of/usr/bin. The brew package, such as NumPy, will be installed under Local/python/site-package. Brew Install Python installs the new PIP to the local directory. After the need for brew against brewed Python lib new software such as Macvim, will automatically find the first occurrence of the Python lib from $path. Under Ipython, the Import OS, print (Os.path) can see the path to the $pythonpath, which indicates which python to use. After import numpy, print numpy.___path__ can see which path the import is under NumPy.

Install installinstall scipy 

1.2 Ipython

InstallinstallBrew Test numpybrew test scipy

Install installinstall ipython[zmq,qtconsole,notebook,test] 

1.3 x11

A version of the x.org x Window System that runs on OS X

X11 is a graphics system, Ubuntu is to use X11 to display the graphical interface, Pyhton Matplotlib can also use X11, you can also use agg in the X11 do not start when using plot, refer to here . Mac has its own set of graphical interfaces, but it also provides X11 support (see here ).

2. Remote ubuntu12.04 settings

2.1 Theano, Python, Ipython installation, ( see Theano official )

2.2 Compile and install the Vim7.4+python version , refer to here ,? I failed to join Python support several times, and then did not choose--enable-perlinterp at compile time \-- ENABLE-LUAINTERP \--enable-gui=gtk2--enable-cscope-prefix=/usr These three components were successfully added to Python support, it's strange, I guess, the reason for Luain.

2.3 Youcompleteme Installation , refer to the official .

3. Mac and Ubuntu connectivity

I use vim to write Python code on my Mac via SSH to Ubuntu. Debugging I want to be able to remotely connect to Ubuntu's Ipython pdb on Mac

To Debug. Debug method Reference here . The question is how do I create a link to a remote python? Ipython's detached design gives me the opportunity to see.

The Ipython is divided into two separate sections of the kernel and frontend front-end interfaces. Kerner can run on Ubuntu, while Frontend can run on a Mac.

3.1 Method 1, connect the remote kernel with Qtconsole on Mac (see 1 2)

Ubuntu side:

Start Ipython kernel on Ubuntu and bind to IP so that kernel is available on 192.168.2.6 41746 52697 52331 33016 58260 of these 5 ports.

Server > Ipython qtconsole-ip=192.168. 2.6

Here can also use Ipython kernel to start, but then the wood has X11 or agg support.

Use command%connect_info to view connection information in Ipython after startup.

{  "Stdin_port":41746,   "IP":"192.168.2.6",   "Control_port":52697,   "Hb_port":52331,   "Signature_scheme":"hmac-sha256",   "Key":"8c035c48-3fd1-4492-801d-aad6bda49293",   "Shell_port":33016,   "Transport":"TCP",   "Iopub_port":58260}

A file with the above content will be generated automatically after startup, this file can be found in the following directory

ls . ipython/profile_default/security/Kernel-10436. JSON  kernel-11114. JSON  kernel-7780. JSON

Mac side:

Copy connection file to local

SCP 9997 [email protected]61.61. 61.61:/home/congliu/profile_default/security/kernel-10436. Json./

Start frontend, connect to the firewall 61.61.61.61 behind the 192.168.2.6. In fact, the port mapping function with SSH first put Mac on Qtconsole on 127.0.0.1 41746 52697 52331 33016 58260 This 5 port access forwarding to the corresponding port of the remote 192.168.2.6, because Ubuntu is behind the firewall, so it also uses the SSH tunnel to connect the Mac and the 61.61.61.61.

[Email protected]~] $ipython qtconsole-ssh[email protected]61.61. 61.61:9997  --ip=192.168.  2.6 --existing./kernel-11114. JSON

3.2 Method 2, connect the remote kernel with notebook on Mac (refer to here )

3.3 Method 3, use SSH's x11 forwarding function (refer to here )

SSH is really powerful, can be on Ubuntu through the X11 display graphics, forward to the Mac display, of course, the premise is on the Mac to install the X11 service (see here ). Typing Ipython qtconsole on the Ubuntu command line is a qtconsole open on your Mac. At this point, the Python and Ipython on your Mac are not running at all, and the X11 on your Mac is receiving instructions from X11 on Ubuntu and then displaying them locally. Ipython kernel and frontend are also running on Ubuntu.

Coding Theano under remote ubuntu server from local mac (on local Mac machine, write, run, debug, see-Theano code on remote Ubuntu)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.