Get your Data Science environment ready in Ubuntu 20.04

Jetbrains ToolBox

If you have previously worked with any Jetbrains software such as Pycharm, you will definitely find ToolBox very useful. It basically allows you to install and manage all Jetbrains software using a simple interface.

  1. Go to their website and download the tar.gz

NVIDIA Drivers [Optional]

This part only applies if your computer has a GPU.

sudo ubuntu-drivers devices
sudo ubuntu-drivers autoinstall
sudo reboot

CUDA [Optional]

CUDA is basically a parallel computing platform to do mathematical operations using the GPU. It is a necessary requirement to train Deep Learning algorithms using tools such as Tensorflow or Pytorch.

sudo apt updatesudo apt install nvidia-cuda-toolkit
nvcc --versionf

Install virtualenv with Python 3

sudo apt-get install python3-pip
pip3 install virtualenv
which python3
virtualenv -p /home/username/opt/python-3.10.1/bin/python3 myPythonEnv

OpenCV

I first tried to install it using the Ubuntu Repository

sudo apt install libopencv-dev python3-opencv
while getopts p: flag
do
case "${flag}" in
p) path=${OPTARG};;
esac
done
echo "path: $path";

sudo apt update
sudo apt upgrade
sudo apt-get install build-essential cmake unzip pkg-config -y
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev -y
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y
sudo apt-get install libxvidcore-dev libx264-dev -y
sudo apt-get install libgtk-3-dev -y
sudo apt-get install libatlas-base-dev gfortran -y
sudo apt-get install python3-dev -y
cd ~
rm -rf opencv
rm -rf opencv_contrib
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.5.0.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.5.0.zip
unzip opencv.zip
unzip opencv_contrib.zip
mv opencv-4.5.0 opencv
mv opencv_contrib-4.5.0 opencv_contrib
cd ~/opencv
mkdir build
cd build
source ~/$path/bin/activate
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D PYTHON_EXECUTABLE=~/$path/bin/python \
-D BUILD_EXAMPLES=ON ..
make -j4
sudo make install
sudo ldconfig
cd /usr/local/lib/python3.8/site-packages/cv2/python-3.8
sudo mv cv2.cpython-38-x86_64-linux-gnu.so cv2.so
cd ~/$path/lib/python3.8/site-packages
ln -s /usr/local/lib/python3.8/site-packages/cv2/python-3.8/cv2.so cv2.so
bash install_opencv.sh -p .env/myPythonEnv

Pytorch

Many people would love to use Tensorflow, but I am a Pytorch guy, so sorry :).

pip install torch torchvision torchaudio

Conclusions

I hope this post has been of use to you. If you consider there is more software that should be in your basic Data Science setup, just leave it in the comments.

Links

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Roberto Diaz

Roberto Diaz

6 Followers

Data Scientist. Passionate about tech. I write about Machine Learning and Cloud Computing.