Title: Your deep learning + Python Ubuntu virtual machine - PyImageSearch

URL Source: https://pyimagesearch.com/2017/09/22/deep-learning-python-ubuntu-virtual-machine/

Published Time: 2017-09-22T14:00:54+00:00

Markdown Content:
[![Image 1](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20479'%3E%3C/svg%3E)](https://pyimagesearch.com/wp-content/uploads/2017/09/deep_learning_vm_header.png)

When it comes to working with deep learning + Python I _highly recommend_ that you use a Linux environment.

Deep learning tools can be more easily configured and installed on Linux, allowing you to develop and run neural networks quickly.

Of course, configuring your own deep learning + Python + Linux development environment can be quite the tedious task, _especially_ if you are new to Linux, a beginner at working the command line/terminal, or a novice when compiling and installing packages by hand.

In order to help you jump start your deep learning + Python education, I have created an _**Ubuntu virtual machine**_ with all necessary deep learning libraries you need to successful (including _Keras_, _TensorFlow_, _scikit-learn_, _scikit-image_, _OpenCV_, and others) _**pre-configured**_ and _**pre-installed**_.

This virtual machine is part of all three bundles of my book, [_Deep Learning for Computer Vision with Python_](https://pyimagesearch.com/deep-learning-computer-vision-python-book/). After you purchase your copy you’ll be able to download the virtual machine and get started with deep learning immediately.

In the remainder of this tutorial I’ll show you:

*   How to download and install _VirtualBox_ for managing, creating, and importing virtual machines.
*   How to import the pre-configured _Ubuntu_ virtual machine for deep learning.
*   How to access the _pre-installed deep learning libraries_ on the virtual machine.

Let’s go ahead and get started.

Your purchase of [_Deep Learning for Computer Vision with Python_](https://pyimagesearch.com/deep-learning-computer-vision-python-book/) includes a pre-configured Ubuntu virtual machine for deep learning. In the following sections I’ll show you how easy it is to import your Ubuntu deep learning virtual machine.

This tutorial is broken down into three parts to make it easy to digest and understand:

1.  Download and install VirtualBox.
2.  Download and import your pre-configured Ubuntu deep learning virtual machine.
3.  Access the Python development environment inside the deep learning virtual machine.

### Step #1: Download and install VirtualBox

The first step is to download [VirtualBox](https://www.virtualbox.org/), a free open source platform for managing virtual machines.

VirtualBox will run on _**macOS**_, _**Linux**_, and _**Windows**_.

We call the physical hardware VirtualBox is running on your _**host machine**_. The virtual machine that will be imported into VirtualBox is the _**guest machine**_.

To install VirtualBox, first visit the [downloads page](https://www.virtualbox.org/wiki/Downloads) and then select the appropriate binaries for your operating system:

![Image 2](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20261'%3E%3C/svg%3E)

**Figure 1:** VirtualBox downloads.

From there install the software on your system following the provided instructions — I’ll be using macOS in this example, but again, these instructions will also work on Linux and Windows as well:

![Image 3](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20450%20260'%3E%3C/svg%3E)

**Figure 2:** Installing VirtualBox on macOS

### Step #2: Download your deep learning virtual machine

Now that VirtualBox is installed you need to download the pre-configured Ubuntu virtual machine associated with your purchase of _[Deep Learning for Computer Vision with Python](https://pyimagesearch.com/deep-learning-computer-vision-python-book/):_

![Image 4](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20271'%3E%3C/svg%3E)

**Figure 3:** Downloading the pre-configured Ubuntu deep learning virtual machine.

The file is approximately 4GB so depending on your internet connection this download make take some time to complete.

Once you have downloaded the `VirtualMachine.zip` file, unarchive it and you’ll find a file named `DL4CV Ubuntu VM.ova` . I have placed this file on my Desktop:

![Image 5](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20367%20400'%3E%3C/svg%3E)

**Figure 4:** The DL4CV Ubuntu VM.ova file.

This is the actual file that you will be importing into the VirtualBox manager.

### Step #3: Import the deep learning virtual machine into VirtualBox

Go ahead and open up the VirtualBox manager.

From there select `File => Import Appliance...` :

![Image 6](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20482'%3E%3C/svg%3E)

**Figure 5:** Importing the pre-configured Ubuntu deep learning virtual machine.

Once the dialog opens you’ll want to navigate to where the `DL4CV Ubuntu VM.ova` file resides on disk:

![Image 7](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20488'%3E%3C/svg%3E)

**Figure 6:** Selecting the pre-configured Ubuntu deep learning virtual machine.

Finally, you can click _“Import”_ and allow the virtual machine to import:

![Image 8](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20446'%3E%3C/svg%3E)

**Figure 7:** Importing the Ubuntu deep learning virtual machine may take 3-4 minutes depending on your system.

The entire import process should take only a few minutes.

### Step #4: Boot the deep learning virtual machine

Now that the deep learning virtual machine has been imported we need to boot it.

From the VirtualBox manager select the _“DL4CV Ubuntu VM”_ on the left pane of the window and then click _“Start”_:

![Image 9](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20444'%3E%3C/svg%3E)

**Figure 8:** Booting the pre-configured Ubuntu deep learning virtual machine.

Once the virtual machine has booted you can login using the following credentials:

*   **Username:** `pyimagesearch`
*   **Password:** `deeplearning`

![Image 10](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20485'%3E%3C/svg%3E)

**Figure 9:** Logging into the deep learning virtual machine.

### Step #5: Access the deep learning Python virtual environment

The next step after logging into the VM is to launch a terminal:

![Image 11](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20485'%3E%3C/svg%3E)

**Figure 10:** Launching a terminal window.

From there, execute `workon dl4cv` to access the Python + deep learning development environment:

![Image 12](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20485'%3E%3C/svg%3E)

**Figure 11:** Accessing the _dl4cv_ deep learning + Python development environment.

Notice that my prompt now has the text `(dl4cv)` preceding it, implying that I am inside the `dl4cv` Python virtual environment.

You can run `pip freeze` to see all the Python libraries installed.

I have included a screenshot below demonstrating how to import Keras, TensorFlow, and OpenCV from a Python shell:

[![Image 13](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20491'%3E%3C/svg%3E)](https://pyimagesearch.com/wp-content/uploads/2017/09/deep_learning_vm_python_imports.png)

**Figure 12:** Importing Keras, TensorFlow, and OpenCV into our deep learning Python virtual environment.

### Step #6: (Optional) Install Guest Additions on virtual machine

An optional step you may wish to perform is installing the _VirtualBox Guest Additions_ on your machine.

The Guest Additions package allow you to:

*   Copy and paste from the virtual machine to your host (and vice versa)
*   Share folders between the virtual machine and host
*   Adjust screen resolution
*   etc.

You can install the Guest Additions by selecting `Devices => Install Guest Additions...` from the VirtualBox menu at the top of your screen.

### Executing code from _Deep Learning for Computer Vision with Python_ on your virtual machine

There are multiple methods to access the _Deep Learning for Computer Vision with Python_ source code + datasets from your virtual machine.

_**By far the easiest method**_ is to simply open Firefox and download the .zip archives from the _“Your Purchase”_ page after buying your copy of _Deep Learning for Computer Vision with Python_. I would recommend forwarding the receipt email to yourself so you can login to your inbox via Firefox and then download the code + datasets.

You may also use your favorite SFTP/FTP client to transfer the code from your host machine to the virtual machine.

Of course, you can always manually write the code inside Ubuntu virtual machine using the built-in text editor as you follow along with the book.

### Tips for using the deep learning virtual machine

When using the Ubuntu VirtualBox virtual machine for deep learning I recommend the following:

*   **Use [Sublime Text](https://www.sublimetext.com/) as a lightweight code editor.** Sublime Text is my favorite code editor for Linux. It’s simple, easy to use, and very lightweight, making it ideal for a virtual machine.
*   **Use [PyCharm](https://www.jetbrains.com/pycharm/) as a full blown IDE.** When it comes to Python IDEs, it’s hard to beat PyCharm. I personally don’t like using PyCharm inside a virtual machine as it’s quite resource hungry. You’ll also need to configure PyCharm to use the `dl4cv` Python environment once installed.

### Troubleshooting and FAQ

In this section I detail answers to frequently asked questions and problems regarding the pre-configured Ubuntu deep learning virtual machine.

#### How do I boot my deep learning virtual machine?

Once your VM has been imported, select the _“DL4CV Ubuntu VM”_ on the left-hand side of the VirtualBox software, then click the _“Start”_ button. Your VM will then boot.

#### What is the username and password for the Ubuntu deep learning virtual machine?

The username is `pyimagesearch` and the password is `deeplearning` .

#### The username and password is not working for me.

The keyboard layout chosen for the Ubuntu virtual machine is the standard _**English layout**_. If you are using a keyboard in a different language than English please add the keyboard layout for your specific language.

To accomplish this, first open the system settings application and select _“Keyboard”_. From there, click the _“Text Entry”_ button at the bottom of the panel:

![Image 14](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20482'%3E%3C/svg%3E)

Figure 13: Selecting “Text Entry” in the deep learning virtual image.

Lastly, click the _“+”_ icon, select your keyboard layout, and click _“Add”_:

![Image 15](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20600%20482'%3E%3C/svg%3E)

**Figure 14:** Updating the keyboard layout in the Ubuntu virtual machine.

You may need to reboot your system for these changes to take effect.

#### How do I run Python scripts that access deep learning libraries?

The _Deep Learning for Computer Vision with Python_ virtual machine uses [Python virtual environments](https://realpython.com/blog/python/python-virtual-environments-a-primer/) to help organize Python modules and keep them separate from the system install of Python.

To access the virtual environment simply execute `workon dl4cv` from the shell. Form there you’ll have access to deep learning/computer vision libraries such as TensorFlow, Keras, OpenCV, scikit-learn, scikit-image, etc.

#### How can I access my GPU from the Ubuntu virtual machine?

The short answer is that you cannot access your GPU from the virtual machine.

A virtual machine abstracts your hardware and creates an artificial barrier between your host machine and your guest machine. Peripherals such as your GPU, USB ports, etc. on your physical computer cannot be accessed by the virtual machine.

If you would like to use your GPU for deep learning I would suggest configuring your native development environment.

#### I am receiving an error message related to _“VT-x/AMD-V hardware acceleration is not available for your system”_. What do I do?

If you are getting an error message similar to the following:

![Image 16](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20303%20164'%3E%3C/svg%3E)

**Figure 13:** Resolving “VT-x/AMD-V hardware acceleration is not available for your system” errors.

Then you likely need to check your BIOS and ensure virtualization is enabled. If you’re on Windows you might also need to disable Hyper-V mode.

To resolve the problem:

1.  **Disable Hyper-V mode from the Windows control panel (if using the Windows operating system).** Take a look at the answers to this [question](http://superuser.com/questions/597121/vt-x-amd-v-hardware-acceleration-is-not-available-on-your-system), which is the same problem you are having. Disabling Hyper-V is different on different Windows versions, but following the answer to the question above you should be able to find your solution. That said, also make sure you do step 2 below as well.
2.  **Check your BIOS.** The next time you boot your system, go into the BIOS and ensure that Virtualization is enabled (normally it’s under some sort of “advanced setting”). If virtualization is not enabled, then the VM will not be able to boot.

### What's next? We recommend [PyImageSearch University](https://pyimagesearch.com/pyimagesearch-university/?utm_source=blogPost&utm_medium=bottomBanner&utm_campaign=What%27s%20next%3F%20I%20recommend).

**Course information:**  
84 total classes • 114+ hours of on-demand code walkthrough videos • Last updated: February 2024  
★★★★★ 4.84 (128 Ratings) • 16,000+ Students Enrolled

**I strongly believe that if you had the right teacher you could _master_ computer vision and deep learning.**

Do you think learning computer vision and deep learning has to be time-consuming, overwhelming, and complicated? Or has to involve complex mathematics and equations? Or requires a degree in computer science?

That’s _not_ the case.

All you need to master computer vision and deep learning is for someone to explain things to you in _simple, intuitive_ terms. _And that’s exactly what I do_. My mission is to change education and how complex Artificial Intelligence topics are taught.

If you're serious about learning computer vision, your next stop should be PyImageSearch University, the most comprehensive computer vision, deep learning, and OpenCV course online today. Here you’ll learn how to _successfully_ and _confidently_ apply computer vision to your work, research, and projects. Join me in computer vision mastery.

**Inside PyImageSearch University you'll find:**

*   ✓ **84 courses** on essential computer vision, deep learning, and OpenCV topics
*   ✓ **84 Certificates** of Completion
*   ✓ **114+ hours** of on-demand video
*   ✓ **Brand new courses released _regularly_**, ensuring you can keep up with state-of-the-art techniques
*   ✓ **Pre-configured Jupyter Notebooks in Google Colab**
*   ✓ Run all code examples in your web browser — works on Windows, macOS, and Linux (no dev environment configuration required!)
*   ✓ Access to **centralized code repos for _all_ 536+ tutorials** on PyImageSearch
*   ✓ **Easy one-click downloads** for code, datasets, pre-trained models, etc.
*   ✓ **Access** on mobile, laptop, desktop, etc.

[Click here to join PyImageSearch University](https://pyimagesearch.com/pyimagesearch-university/?utm_source=blogPost&utm_medium=bottomBanner&utm_campaign=What%27s%20next%3F%20I%20recommend)

Summary
-------

In today’s tutorial I demonstrated:

*   How to download and install VirtualBox, the software used to manage virtual machines.
*   How to import and launch your Ubuntu deep learning virtual machine.
*   How to access the deep learning development environment once Ubuntu has booted.

All purchases of my book, [_Deep Learning for Computer Vision with Python_](https://pyimagesearch.com/deep-learning-computer-vision-python-book/), include a copy of my pre-configured virtual machine.

This virtual machine is _by far_ the fastest way to get up and running with deep learning and computer vision using the Python programming language.

**If you would like to learn more about my new book (and pick up a copy yourself), [_just click here_](https://pyimagesearch.com/deep-learning-computer-vision-python-book/).**

![Image 17](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20410%20567'%3E%3C/svg%3E)

#### Join the PyImageSearch Newsletter and Grab My FREE 17-page Resource Guide PDF

Enter your email address below to **join the PyImageSearch Newsletter** and **download my FREE 17-page Resource Guide PDF** on Computer Vision, OpenCV, and Deep Learning.