ChromeOS Crostini Machine Learning Setup

Thank You for using the ChromeOS Crostini Machine Learning Setup Script to setup your device for Machine Learning. We live in a age where Machine Learning will be deeply integrated into just about all future software projects. I honestly cannot wait to hear about what you create with these tools. Please feel free to drop me a note if you have a project to share.

Please sign up for my mailing list or follow the project on github for updates.

Requirements

You will need the following in order to use this tool:

  • A X86_64 Chromebook such as the Pixelbook or Pixel Slate (ARM Chromebooks are not supported at this time)
  • Plenty of Space – I recommend your Chromebook having at least 256 GB of Local Storage
  • Time – Some of these tools will take a while to download and build. It is recommended that you not use a metered WiFi connection or mobile data connection

Installation

Run the following from a Linux Terminal on your Chromebook

cd ~/
sudo apt install -y wget && bash <(wget -qO- https://raw.githubusercontent.com/KeithIMyers/Crostini-Machine-Learning/master/CrostiniMLSetup);

Options

Install Conda with TensorFlow and Keras

This will setup miniconda with Tensorflow and all dependencies. This option will create a pre-configured python3 virtual environment called “tensorflow_env”. The installation may take between 3 and 30 minutes depending on your internet speed and Chromebook model. This will also install Keras and Pytorch.

Build and Install OpenCV

‘OpenCV is used by several machine learning tools that involve vision or examining items in photos. It is also used for text analysis and countless other examples. The process to build OpenCV from source is a bit complicated, fortunately this tool will do it all for you. This option will take around 35-40 minutes on a high-end Pixelbook and longer on lower end units. No need to babysit the process, just make sure your Chromebook is connected to a power source and grab a coffee.

Setup udev rules for Intel Movidius Neural Compute Stick 1/2

This will setup your Chromebook to work with the Intel Movidius Neural Compute Stick which exponentially improves inferencing speeds on tasks involving computer vision. In order to use this option, you will need to do the following;

  • Ensure the “Build and Install OpenCV” option is checked
  • Purchase a Movidius Compute Stick
  • Purchase a OTG Cable or a preferably a USB-C Hub if your Chromebook lacks USB A Ports
  • Enable the following Flag in chrome://flags
    • crostini-usb-allow-unsupported
  • Restart your Chromebook

You will need to download and install the OpenVINO toolkit from Intel’s Website, unfortunately this is not something I can script or re-distribute as you need to accept Intel’s License before downloading it.

Setup Google Coral Edge TPU (Experimental)

This will download the Google Coral Edge TPU software and patch the installer to allow it to run on a Chromebook. During the installation, you will be asked  “Would you like to enable the maximum operating frequency?” – Google highly advises you enter “N” on this prompt which will under-clock the TPU to ensure it runs at a safe temperature. If you choose to run it at the max frequency, please read and understand the entire disclaimer before hitting “Y”.

Note : I have this listed as experimental as I do not currently own a Google Coral TPU and therefore have not been able to test this. I am saving up some funds to purchase this in the future.

In order to use this option, you will need to do the following;

  • Ensure the “Build and Install OpenCV” option is checked
  • Purchase a Google Coral Edge TPU
  • Purchase a OTG Cable or a preferably a USB-C Hub if your Chromebook lacks USB A Ports
  • Enable the following Flag in chrome://flags
    • crostini-usb-allow-unsupported
  • Restart your Chromebook

Create Tensorflow Hello Sample Script

This will create a sample Hello World Python script that will invoke Tensorflow and display the text “Hello World, from TensorFlow!” if successful. You will also see some debug output created from Tensorflow that will display statistics of your hardware. You can run the sample code by pasting the following lines into a terminal window.

cd ~
conda activate tensorflow_env
python3 SampleTFHelloWorld.py
conda deactivate

If successful, you will see some output that resembles

(tensorflow_env) keithiokepamyers@penguin:~$ python3 SampleTFHelloWorld.py 
2019-04-25 22:45:53.978892: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2019-04-25 22:45:53.986826: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 1607975000 Hz
2019-04-25 22:45:53.987368: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x593506fe40e0 executing computations on platform Host. Devices:
2019-04-25 22:45:53.987408: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): <undefined>, <undefined>
OMP: Info #212: KMP_AFFINITY: decoding x2APIC ids.
OMP: Info #213: KMP_AFFINITY: x2APIC ids not unique - decoding legacy APIC ids.
OMP: Info #149: KMP_AFFINITY: Affinity capable, using global cpuid info
OMP: Info #154: KMP_AFFINITY: Initial OS proc set respected: 0-3
OMP: Info #156: KMP_AFFINITY: 4 available OS procs
OMP: Info #157: KMP_AFFINITY: Uniform topology
OMP: Info #159: KMP_AFFINITY: 1 packages x 1 cores/pkg x 4 threads/core (1 total cores)
OMP: Info #214: KMP_AFFINITY: OS proc to physical thread map:
OMP: Info #171: KMP_AFFINITY: OS proc 0 maps to package 0 thread 0 
OMP: Info #171: KMP_AFFINITY: OS proc 1 maps to package 0 thread 1 
OMP: Info #171: KMP_AFFINITY: OS proc 2 maps to package 0 thread 2 
OMP: Info #171: KMP_AFFINITY: OS proc 3 maps to package 0 thread 3 
OMP: Info #250: KMP_AFFINITY: pid 27439 tid 27439 thread 0 bound to OS proc set 0
2019-04-25 22:45:53.988687: I tensorflow/core/common_runtime/process_util.cc:71] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
b'Hello World, from TensorFlow!'
(tensorflow_env) keithiokepamyers@penguin:~$

Frequently Asked Questions

How can I launch the Tensorflow Python Virtual Environment?

You can launch the Virtual Environment with Tensorflow pre-configured by running the following command

conda activate tensorflow_env

How can I leave the Tensorflow Virtual Environment?

conda deactivate

Does this have GPU Acceleration?

No, This does mean that you will likely not want to do any training on your Chromebook.

Can I run training sets on my Chromebook?

Technically the answer is yes but I advise against it. I would personally stick with using pre-trained models or offload training to another computer

What about external GPUs?

If I had one, I would test. It is safe to assume the answer is likely no

Facebooktwittergoogle_plusredditpinterestlinkedinmail
Advertisements