ML Environment: Difference between revisions

From CCN Wiki
Jump to navigation Jump to search
No edit summary
Line 14: Line 14:
=Setup=
=Setup=
==TensorFlow Installation==
==TensorFlow Installation==
First off, you can use Conda, but don't use Conda to install TensorFlow. Instead, follow the [https://www.tensorflow.org/install/pip pip install instructions] published by the TensorFlow people.
First off, you can use Conda, but don't use Conda to install TensorFlow. Instead, follow the [https://www.tensorflow.org/install/pip pip install instructions] published by the TensorFlow people. The steps are broadly described below:
===Create a virtual environment===
The first step is to install miniconda if it isn't already installed. Then, create a new Python 3.9 virtual environment:
conda create --name tf python=3.9
Then activate your new environment:
conda activate tf


===Update pip and install tensorflow===
You'll need to update pip first. Then pip install tensorflow
==Spyder Installation==
==Spyder Installation==
Anthony got me using the Spyder IDE for Python programming. Problem is, as of today (July 6, 2022), it's buggy on Ubuntu 22.04. Don't bother using the apt package. Instead, you can install it using pip, as documented [https://bugs.launchpad.net/ubuntu/+source/spyder/+bug/1968479 here]:
Anthony got me using the Spyder IDE for Python programming. Problem is, as of today (July 6, 2022), it's buggy on Ubuntu 22.04. Don't bother using the apt package. Instead, you can install it using pip, as documented [https://bugs.launchpad.net/ubuntu/+source/spyder/+bug/1968479 here]:
  pip install -U spyder
  pip install -U spyder
After installation, you can launch it from a terminal window:
Note that pip will have installed spyder into a specific virtual environment (e.g., tf). You won't be able to launch spyder without first activating that virtual environment. After installation, you can launch it from a terminal window:
  <span style="color:green">user@host</span>:~ spyder
  (base) <span style="color:green">user@host</span>:~ conda activate tf
(tf) <span style="color:green">user@host</span>:~ spyder

Revision as of 19:01, 6 July 2022

The lab primarily uses a Linux environment. We have several workstations running the latest version of Ubuntu. Our machine learning (ML) research is primarily carried out using Google's TensorFlow libraries, written for Python. Workstations with powerful GPUs can use CUDA for GPU acceleration.

Below are the specs and walkthrough for setting up a modest ML programming environment.

Hardware

There are no particular hardware requirements for running TensorFlow. Obviously, more disk space and RAM are desirable, as is a CUDA-enabled GPU.

Operating System

The closed Apple ecosystem might make MacOS a good choice of platform because a Mac is a Mac is a Mac. However, I'm not Mr. Moneybags over here, and Apple drops support for older hardware after a time. You couldn't pay me to use Windows for anything but Office applications, so that leaves Linux. The TensorFlow installation directions assume Ubuntu 16.04 or higher, and though I have dabbled with Debian Linux for a home media server, I typically use Ubuntu. These instructions assume Ubuntu 22.04 LTS.

Python Version

Ubuntu 22.04 has retired Python 2.x, and uses Python 3.9 by default, which works nicely with TensorFlow (I understand that getting TensorFlow to work with Python 3.10+ includes some challenges). These instructions assume Python 3.9. If you want to use other versions of Python for other applications, I recommend using virtual environments to manage and switch between Python versions. The pip installation instructions use miniconda to create a Python 3.9 virtual environment.

Setup

TensorFlow Installation

First off, you can use Conda, but don't use Conda to install TensorFlow. Instead, follow the pip install instructions published by the TensorFlow people. The steps are broadly described below:

Create a virtual environment

The first step is to install miniconda if it isn't already installed. Then, create a new Python 3.9 virtual environment:

conda create --name tf python=3.9

Then activate your new environment:

conda activate tf

Update pip and install tensorflow

You'll need to update pip first. Then pip install tensorflow

Spyder Installation

Anthony got me using the Spyder IDE for Python programming. Problem is, as of today (July 6, 2022), it's buggy on Ubuntu 22.04. Don't bother using the apt package. Instead, you can install it using pip, as documented here:

pip install -U spyder

Note that pip will have installed spyder into a specific virtual environment (e.g., tf). You won't be able to launch spyder without first activating that virtual environment. After installation, you can launch it from a terminal window:

(base) user@host:~ conda activate tf
(tf) user@host:~ spyder