Skip to content

Instantly share code, notes, and snippets.

@mindcont
Last active October 6, 2018 01:48
Show Gist options
  • Save mindcont/25a0432db9c5422ed59c592c1a397f58 to your computer and use it in GitHub Desktop.
Save mindcont/25a0432db9c5422ed59c592c1a397f58 to your computer and use it in GitHub Desktop.
Linux平台常用配置

常用软件

#新立得软件包 (synaptic)
sudo apt-get install synaptic

# ibus 谷歌拼音
sudo apt-get install ibus-googlepinyin
ibus-setup

http://www.jianshu.com/p/905062d201a8

# 经典菜单(classicMenu Indicator)
Ubuntu 14.04 LTS可以通过软件中心搜索安装。

# 交互式python Jupyter
sudo pip install ipython==5.0
sudo pip install "ipython[notebook]"
运行
jupyter notebook

# aptitude可以比apt-get更加智能地解决依赖问题
sudo apt-get install aptitude
使用,例如
sudo aptitude install build-essential

# zsh
sudo apt-get install zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

在任务栏显示网速

sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install indicator-netspeed

压缩

zip
# 将torch 文件夹 压缩torch.zip
zip -r torch.zip torch

# 解压到当前目录下
unzip torch.zip
tar
# 将torch 文件夹 压缩torch.tar.gz
tar zcvf torch.tar.gz torch

#解压
tar xvf torch.tar.gz

pip 镜像加速

pip install notebook --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple

类似的还可以编辑全局文件~/.pip/pip.con实现自动使用镜像地址

On Unix and Mac OS X the configuration file is: $HOME/.pip/pip.conf
On Windows, the configuration file is: %HOME%\pip\pip.ini


# on Ubuntu LTS
cd ~
gedit .pip/pip.conf


[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

机器学习框架

Torch

安装
# in a terminal, run the commands WITHOUT sudo
git clone https://github.com/torch/distro.git ~/torch --recursive

# 由于网络原因,我们可能无法从github上获取完整的git repo,这里可以使用我2017/04/25保存的torch版本
wget ftp://mindcont.com/Download/torch/torch.zip

#安装
cd ~/torch; bash install-deps;
./install.sh
测试

打开一个新的命令行窗口,输入th

pi@DEEPMIND:~$ th

  ______             __   |  Torch7
 /_  __/__  ________/ /   |  Scientific computing for Lua.
  / / / _ \/ __/ __/ _ \  |  Type ? for help
 /_/  \___/_/  \__/_//_/  |  https://github.com/torch
                          |  http://torch.ch

th>

具体参考 http://torch.ch/docs/getting-started.html

Tensorflow

安装
# python2.7 CPU 模式
wget ftp://mindcont.com/Download/tensorflow/python2.7/tensorflow-1.0.1-cp27-none-linux_x86_64.whl

sudo pip install --upgrade tensorflow-1.0.1-cp27-none-linux_x86_64.whl

# python2.7 GPU 模式(为了区分cpu和gpu ,我这里加入了后缀)
值得注意的是,对于GPU模式,tersorflow 0.8 匹配 Ubuntu/Linux 64-bit, GPU enabled, Python 2.7. Requires CUDA toolkit 7.5 and CuDNN v4
ftp://mindcont.com/Download/tensorflow/python2.7/tensorflow-0.8.0-cp27-none-linux_x86_64.whl.gpu

mv tensorflow-0.8.0-cp27-none-linux_x86_64.whl.gpu tensorflow-0.8.0-cp27-none-linux_x86_64.whl
sudo pip install --upgrade tensorflow-1.0.1-cp27-none-linux_x86_64.whl

更多版本可以从 ftp://mindcont.com/Download/tensorflow下载

运行 TensorFlow

打开一个 python 终端:

$ python

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print sess.run(hello)
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print sess.run(a+b)
42
>>>

这里可能会报错

from . import _html5lib
File "/usr/lib/python2.7/dist-packages/bs4/builder/_html5lib.py", line 57, in <module>
class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
AttributeError: 'module' object has no attribute '_base'

需要升级

pip install --upgrade html5lib

我的测试运行结果:

pi@DEEPMIND:~$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcurand.so locally
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:900] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_init.cc:102] Found device 0 with properties:
name: Quadro K6000
major: 3 minor: 5 memoryClockRate (GHz) 0.9015
pciBusID 0000:84:00.0
Total memory: 11.91GiB
Free memory: 11.52GiB
I tensorflow/core/common_runtime/gpu/gpu_init.cc:126] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_init.cc:136] 0:   Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:755] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Quadro K6000, pci bus id: 0000:84:00.0)
>>> print sess.run(hello)
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print sess.run(a+b)
42
>>>

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment