Everyone who has tried to mess around with their Ubuntu distro knows the pain of having to reinstall Ubuntu and set it up to their liking again
These are the scripts that I use to set my Ubuntu up as quick as possible. Feel free to fork it and create your own version, and any contributions are more than welcome :)
Every script is rock stable and runs against Travis CI to make sure everything works as expected. Note that Build-ML.sh
is not shown here as it takes >2 hours to build TF+Pytorch on the Travis systems from source, and 2 hours is the system limit for free accounts on Travis. You can, however, still see the results of it running here
1-BasicSetUp and 2-GenSoftware | 3-ML-Basic | Build-OpenCV | Build-OpenCV in a conda env |
---|---|---|---|
First download/clone this repository
Then execute them in the terminal in the sequence of filenames using ./1-BasicSetUp.sh
, /2-GenSoftware.sh
, and so on.
1-BasicSetUp.sh
- Sets up terminal configuration, a download accelerator, anaconda python, and shell aliases.2-GenSoftware.sh
- Sets up tools for programming(editor, etc), and other general purpose software I use3-ML-Basic.sh
- Installs from pip/conda commonly used DL libraries, and also installs the latest cuda if no cuda is detectedAdditional scripts to built libraries from source:
Build-ML.sh
- Compiles commonly used ML/DL libraries from source, so that it is optimized to run on your computerBuild-OpenCV.sh
- Compiles the latest tag of OpenCV+Contrib from source on your machine with focus on optimization of execution of OpenCV code./opt/anaconda3/
so that it is accessible by multiple usersmaxvol
: Will set your volume to 150%download <webpage-name>
: Download the webpage and all sub-directories linked to itserver
: Sets up a server for file sharing in your local network. Whatever is in your current directory will be visible on the ip. It will also print the possible set of IP addresses. To access from another computer, shoot up a browser and simply hit ip_add:port
gpom
: Alias for git push origin master
. Will push your current directoryjn
: Starts a jupyter notebook in that directoryjl
: Starts a jupyter lab in that directoryydl "URL"
: Downloads the song at URL
at 128kbps, 44.1kHz in m4a format with the title and song name automatically set in the metadataupdate
: Runs sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove -y
tsux
: Create a tmux session with -u
(so that the icons(battery, etc) are properly displayed at the bottom), and with a window with htop
, nvidia-smi -l 1
and lm-sensors
automatically activated.
tmux
command itselfaria
: For accelerated download of files using aria2c. Runs the following command: aria2c --file-allocation=none -c -x 10 -s 10 -d aria2-downloads
If you are using this script to set up a computer with many users,
first_user
. But make sure you have logged in at least once into the new user so that the home directory of the other user is instantiated.We need to copy the configuration files to the new user, say new_user
. From first_user
's account, run the following after entering the username of the new_user
in the second line of this snippet
cd ~
export NEW_USER=<username_of_new_user>
sudo cp /opt/.zsh/bash_aliases /home/$NEW_USER/.bash_aliases
sudo cp -r ~/.zim/ /home/$NEW_USER/.zim
sudo cp ~/.zimrc /home/$NEW_USER/.zimrc
sudo cp ~/.zlogin /home/$NEW_USER/.zlogin
sudo cp ~/.zshrc /home/$NEW_USER/.zshrc
sudo cp ~/.zshenv /home/$NEW_USER/.zshenv
sudo cp ~/.xbindkeysrc /home/$NEW_USER
sudo mkdir -p /home/$NEW_USER/.config/tilda
sudo cp ~/.config/tilda/config_0 /home/$NEW_USER/.config/tilda/config_0
sudo mkdir -p /home/$NEW_USER/.config/micro
sudo cp ~/.config/micro/bindings.json /home/$NEW_USER/.config/micro/bindings.json
sudo cp ~/.tmux.conf* /home/$NEW_USER/
sudo chown -R $NEW_USER: /home/$NEW_USER/.zim /home/$NEW_USER/.bash_aliases /home/$NEW_USER/.zimrc /home/$NEW_USER/.zlogin /home/$NEW_USER/.zshrc /home/$NEW_USER/.xbindkeysrc /home/$NEW_USER/.config/tilda /home/$NEW_USER/.config/micro /home/$NEW_USER/.tmux.conf*
Make sure that your system time and date is correct and synchronized before running the scripts, otherwise this will cause failure while trying to download the packages.
Build-OpenCV.sh
ffmpeg
that is built from scratch using Markus' script. The ffmpeg
that is built is stored in /opt/ffmpeg-build-script
. While the binaries are copied to /usr/local/bin
, the specific versions of libavcodec
and other referenced libraries are still maintained at /opt/ffmpeg-build-script/workspace/lib
Build-OpenCV.sh
script-D WITH_CUDA
, -D WITH_CUBLAS
, -D WITH_CUFFT
,-D CUDA_FAST_MATH
) are enabled.CUDA_ARCH_BIN
flag as described below.CUDA_ARCH_BIN
such as 30 for Kepler, 61 for Pascal, etc. Information about your GPU can be found at Nvidia's page-D OPENCV_ENABLE_NONFREE=ON
to offAfter OpenCV installation, if you get an error of the sort illegal hardware instructions
when you try to run a python or c++ program, that is because your CPU is an older one (Pentium/Celeron/...). You can overcome this by adding the following to the end of the cmake (just before the ..
)
-D ENABLE_SSE=OFF \
-D ENABLE_SSE2=OFF \
-D ENABLE_SSE3=OFF ..
If you still want to be able to receive the benefits of CPU optimization to whatever extent you can, then hit cat /proc/cpuinfo
and see what sse
s are available under flags
build
folder inside opencv
directory before rebuilding, otherwise strange errors can pop up.Build-ML.sh
--config=v1
to the bazel build commandIf you want to install a specific version of OpenCV or Tensorflow, i.e different from the latest release, make the following changes. The scripts should work with different versions but they haven't been tested
OpenCV
Comment out the line fetching the latest release tag in the Build-OpenCV
script.
Add the line below the above commented out one specifying the OpenCV version which you want like this: latest_tag="3.4.5"
Alternatively, you could just replace $latest_tag
with the tag of the version in the following 2 lines: git checkout -f $latest_tag
Make sure that the tag of the OpenCV version you want is correct. The tags of all the releases can be checked here - https://github.com/opencv/opencv/tags
Tensorflow Similar to above, locate the line fetching the latest release tag of Tensorflow and replace with the tag of the version required. The tags of all the Tensorflow releases can be checked here - https://github.com/tensorflow/tensorflow/tags
These scripts are written and tested on the following configurations -
ML-Build.sh
- NVIDIA GPUs including but not limited to GeForce GTX 1080, 1070, 940MX, 850M, and Titan XAlthough it should work on other configurations out of the box, I have not tested them
Docker Images
Dockerfile
is present in the repository, which builds OpenCV with CUDA support enabled. Customize it as required for specific requirements such as different CUDA versions, CPU-only images, etc.The tmux configuration used is inspired from https://github.com/gpakosz/.tmux
In the description of shortcuts below, meaning of connectors:
+
: The second key is to be pressed while keeping the first key pressed
(space): The previous key/keys are to be released before the next key is pressed/
: You can choose any of the specified keysThe shortcuts within tsux
/tmux
that you can use are:
Ctrl+b \
: Split existing window into two panes verticallyCtrl+b -
: Split existing window into two panes horizontallyAlt+Right/Left/Up/Down
: Switch between the panes of the same windowCtrl+b c
: Create a new window within the tmux sessionCtrl+b Shift+Left/Right
: Switch between the windows of the tmux sessionCtrl+b [
: Go into tmux copy-mode (enable selection of text from the tmux buffer quickly using just your keyboard). Go to your preferred start point, press Space
to start the selection of the copy section. Press Enter
at the end point