Notes for using TensorFlow on Bash on Ubuntu on Windows

With the Windows 10 Anniversary Update, Ubuntu became available on Windows, so I installed TensorFlow.

Reference article

I referred to the following article.

[1] Let's install Bash on Ubuntu on Windows! [2] Install Anaconda on CentOS using pyenv [3] TensorFlow Installation Using conda [4] GUI by Bash on Ubuntu on Windows + Xming [5] Cygwin Absolute Killing Man-Until Physical Nerds Can Calculate Numerically with Windows Subsystem for Linux- [6] Bash on Ubuntu on Windows and X Window combined to display Japanese and input Japanese

Bash installation

Reference article [1].

Anaconda installation

Ubuntu on Windows includes python, but since the version is 2 and it is necessary to add a package, I decided to include Anaconda. However, since the original python is kept, try installing it using pyenv as in Reference article [2]. I did. The procedure is as follows.

Git installation

Install Git for the pyenv installation.

$ sudo apt-get install git

pyenv installation

Install pyenv using Git.

$ git clone https://github.com/yyuu/pyenv ~/.pyenv

pyenv settings

Add pyenv preferences to .bachrc.

$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(pyenv init -)"' >> ~/.bashrc

Anaconda installation

source ~ / .bashrc or restart bash

$ pyenv install --list

Check the version of Anaconda that can be installed with

$ pyenv install anaconda3-4.1.0

Install with.

Python preferences

$ pyenv global anaconda3-4.1.0
$ pyenv rehash

Now, set the Python environment to Anaconda.

TensorFlow installation

There are several ways to install TensorFlow, but since Anaconda is included,

$ conda install -c conda-forge tensorflow

Install with. However, you can only install the CPU version with this.

Now, if you run the sample program in TensorFlow Introduction in Python,

0 [ 0.82097143] [-0.14609614]
20 [ 0.30302274] [ 0.18841095]
40 [ 0.15555] [ 0.26946762]
60 [ 0.1151993] [ 0.29164591]
80 [ 0.10415875] [ 0.2977142]
100 [ 0.1011379] [ 0.29937458]
120 [ 0.10031134] [ 0.29982889]
140 [ 0.10008518] [ 0.29995319]
160 [ 0.10002329] [ 0.2999872]
180 [ 0.10000639] [ 0.2999965]
200 [ 0.10000175] [ 0.29999906]

So, I think TensorFlow installation is OK for the time being.

X11 related installation

Since there is no GUI for Bash alone, I will make it possible to use the X11 application. The quickest way is Xming like Reference article [4]. Is the way to use. (There is also VcXsrv Windows X Server as software similar to Xming.)

After installing Xming or VcXsrv, install the X11 apps and libraries. (You don't have to install x11-apps. If you have an X11 app such as xterm, the required libraries will be installed.)

$ sudo apt-get install x11-apps

Then add your preferences to your .bashrc.

$ echo 'export DISPLAY=localhost:0.0' >> ~/.bashrc

This should work for X11 related apps, but when I try to display a graph using matplotlib in Python,

OMP: Error #100: Fatal system error detected.
OMP: System error #22: Invalid argument

I get an error saying that it stops. It's not limited to matplotlib, but it seems that an error occurs in a package that uses MKL.

$ conda install nomkl

It seems that each package needs to be changed to a non-MKL compatible version.

For the time being, in my environment, I was able to display the graph with matplotlib. ~~ However, it seems that the Japanese display in the graph cannot be done well as it is. ~~ Japanese input can be done by referring to Reference article [6]. Then the Japanese in the matplotlib graph is

from matplotlib.font_manager import FontProperties
fp = FontProperties(fname='C:\Windows\Fonts\YuGothM.ttc', size=14)

Font path

from matplotlib.font_manager import FontProperties
fp = FontProperties(fname='/mnt/c/Windows/Fonts/YuGothM.ttc', size=14)

If you write like, it will be recognized from Bash.

Recommended Posts

Notes for using TensorFlow on Bash on Ubuntu on Windows
Notes for using OpenCV on Windows10 Python 3.8.3.
Try using Bash on Windows 10 2 (TensorFlow installation)
Installation notes for TensorFlow for Windows
Run Tensorflow from Jupyter Notebook on Bash on Ubuntu on Windows
Run XGBoost on Bash on Ubuntu on Windows
[Note] Procedures for installing Ubuntu on Windows 10
Install TensorFlow on Ubuntu
Notes on installing Python3 and using pip on Windows7
Build TensorFlow on Windows
Installing TensorFlow on Windows Easy for Python beginners
Notes on using Alembic
[Heroku] Memo for deploying Python apps using Heroku on Windows [Python]
Install Bash on Ubuntu on Windows, Ruby, Python, Jupyter, etc.
Run Jupyter on Ubuntu on Windows
Try using OpenCV on Windows
F2py on Miniconda for Windows
[Django] Notes on using django-debug-toolbar
Operate ubuntu on VScode (windows10)
Notes on optimization using Pytorch
Introducing TensorFlow on Ubuntu + Python 2.7
[Tensorflow] Tensorflow environment construction on Windows 10
Notes on installing Anaconda 3 on Windows
Don't ask for SSH passphrases using keychain on Ubuntu (linux)
Install CUDA10.1 + cuDNN7.6.5 + tensorflow-2.3.0 on Ubuntu 18.04
Remove ubuntu installed on Windows 10 machine
Introducing Python using pyenv on Ubuntu 20.04
Notes on using MeCab from Python
Preparing python using vscode on ubuntu
Run Tensorflow natively supported on windows
Notes on using post-receive and post-merge
Notes on installing Python using PyEnv
Using a serial console on Ubuntu 20.04
Notes on using rstrip with python.
Install confluent-kafka for Python on Ubuntu
pykintone on Windows Subsystem for Linux
Notes on using matplotlib on the server
Notes on installing Ubuntu 18.04 on the XPS 15 7590
Run Yocto on Ubuntu using QEMU.
(Beginner) Notes on using pyenv on Mac
I tried playing Windows games using Steam Play on Ubuntu 20.04 LTS
[Definitive Edition] Building an environment for learning "machine learning" using Python on Windows
Programming environment for beginners made on Windows
[50 counts] Key transmission using Python for Windows
Notes on implementing APNs tests using Pytest
Notes for setting up pydicom on macOS
Notes for using python (pydev) in eclipse
I built a TensorFlow environment on windows10
Until the Deep Learning environment (TensorFlow) using GPU is prepared for Ubuntu 14.04
Error, warning when using TensorFlow on Mac
Notes on using code formatter in Python
Building an environment for "Tello_Video" on Windows
CPU usage is 100% when using pygame on Ubuntu 16.04
A addictive story when using tensorflow on Android
(Windows) Causes and workarounds for UnicodeEncodeError on Python 3
Tips for using Realsense SR300 on MacBook in 2020
Build procedure for TensorFlow 2.4.0 (Windows10, CUDA11.1.1, cuDNN 8.0.5, Python 3.8.6)
Python development on Ubuntu on AWS EC2 (using JupyterLab)
Installed because Tensorflow has native support for Windows
Beginning cross-compilation for Raspberry Pi Zero on Ubuntu
Build a Kubernetes environment for development on Ubuntu