This article is related to the previous article Effective Jetson Xavier NX Setup - SSD Booting. In the previous article, I explained how to use an SSD instead of an SD card in Xavier NX. When using an SSD, you can get much faster IO speed and superior stability than when using an SD card. And since a large amount of storage space is secured, you do not have to suffer from the small memory capacity of the SD card.
This time, we will think about how to create a SW development environment. Most of the development in the Jetson series will be for vision processing, machine learning, edge AI, device control, etc.
The development language will probably use Python and C/C++ heavily. The most difficult part of building a development environment in Xavier NX is the Python development environment.
For example, if you want to use TensorFlow 1.X and 2.X at the same time, you need to install different Python and packages, so you often use Python virtual environment or Anaconda. And many developers also use Docker. Unlike a virtual machine, Docker is a lightweight microservice that does not have an operating system. However, Docker images are often too large to be used in Jetson series.
In this article, I will explain how to create and work with a Python virtual environment using Anaconda instead of Docker.
Why use a Python virtual environment?
Different versions of Python are available in different versions.
If you have to use TensorFlow 2.8 and 1.12 versions as indicated in the table above, Python is not compatible. So we need two Pythons.
And the versions of packages required for each version of TensorFlow are different. Numpy packages, which are always used in TensorFlow and PyTorch, sometimes cause version problems. For example, if you change the version for a specific package, other packages do not work.
Because of this problem, the TensorFlow installation guide recommends using a virtual environment or Docker image like this.
However, this method creates a virtual environment based on a specific Python version that the system already has installed. So it's not a good idea if you need to use more than one python. The best way is to create a virtual environment using Anaconda, install the version you want from Python, and then install TensorFlow in the virtual environment again.
Anaconda
Anaconda is a conditional free and open source software name that facilitates package/dependency management and distribution of Python and R languages, suitable for scientific research and machine learning fields.
It was originally free, but starting in 2020, it is free only for individual users, universities, non-profit organizations, and small and medium-sized enterprises (SMEs) with less than 200 employees, and has been changed to a fee for the government and companies with 200 or more employees.
And in 2020, the site that used to be anaconda.org was changed to anaconda.com, which was the cloud.
Now anaconda.org is the cloud site.
Anaconda includes most of the packages suitable for scientific research and machine learning applications. Therefore, there is a drawback that the size is quite large. Miniconda is a solution to this problem. Unlike anaconda, only the minimum required for operation is provided, and the user has to find and install the necessary packages himself. However, for this reason, the file is smaller and lighter than Anaconda.
Miniconda is a free minimal installer for conda. It is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others. Use the conda install command to install 720+ additional conda packages from the Anaconda repository.
I'm going to install Anaconda on the Xavier NX. Because I am using an SSD with sufficient capacity.
Installing Anaconda on Xavier NX
There are instructions for installing Anaconda at https://www.anaconda.com/products/individual#Downloads.
Since the Xavier NX we are using is an arrch64 CPU, right-click the link in the picture below to copy the path or download the installation script.
Install Anaconda
wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-aarch64.sh chmod 755 Anaconda3-2021.11-Linux-aarch64.sh ./Anaconda3-2021.11-Linux-aarch64.sh
When Anaconda is installed, the following content is added to the ~/.bashrc file.
So, whenever you open a new shell in the future, these lines will be executed.
# >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! __conda_setup="$('/home/spypiggy/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ $? -eq 0 ]; then eval "$__conda_setup" else if [ -f "/home/spypiggy/anaconda3/etc/profile.d/conda.sh" ]; then . "/home/spypiggy/anaconda3/etc/profile.d/conda.sh" else export PATH="/home/spypiggy/anaconda3/bin:$PATH" fi fi unset __conda_setup # <<< conda initialize <<<
And in the new shell prompt, (base) is added as follows:
(base) spypiggy@spypiggy-desktop:~$
If you do not want to initialize anaconda automatically, you can delete the conda initialization part from your ~/.bashrc file. And only one line related to the following path is left in the ~/.bashrc file.
# >>> conda initialize >>>
export PATH="/home/spypiggy/anaconda3/bin:$PATH"# <<< conda initialize <<<
Important conda commands
The following are important commands to create a virtual environment using anaconda.
- conda search python : Shows the Python versions that can be installed in Anaconda.
(base) spypiggy@spypiggy-xavierNX:~/anaconda3$ conda list # packages in environment at /home/spypiggy/anaconda3: # # Name Version Build Channel _ipyw_jlab_nb_ext_conf 0.1.0 py39hd43f75c_0 _libgcc_mutex 0.1 main _openmp_mutex 5.1 51_gnu adwaita-icon-theme 40.1.1 hd43f75c_1 alabaster 0.7.12 pyhd3eb1b0_0 anaconda 2021.11 py39_0 anaconda-client 1.9.0 py39hd43f75c_0 anaconda-navigator 2.1.1 py39_0 anaconda-project 0.10.1 pyhd3eb1b0_0 anyio 2.2.0 py39hd43f75c_1 appdirs 1.4.4 pyhd3eb1b0_0 argh 0.26.2 py39hd43f75c_0 argon2-cffi 20.1.0 py39h2f4d8fa_1 arrow 0.13.1 py39hd43f75c_0 asn1crypto 1.4.0 py_0 astroid 2.5 py39hd43f75c_1 astropy 4.3.1 py39h08bb699_0 async_generator 1.10 pyhd3eb1b0_0 at-spi2-atk 2.34.2 hf975c6d_0 at-spi2-core 2.36.0 hf975c6d_1 atk-1.0 2.36.0 h920789f_0 atomicwrites 1.4.0 py_0 attrs 21.2.0 pyhd3eb1b0_0 autopep8 1.5.7 pyhd3eb1b0_0 babel 2.9.1 pyhd3eb1b0_0 backcall 0.2.0 pyhd3eb1b0_0 backports 1.0 pyhd3eb1b0_2 backports.functools_lru_cache 1.6.4 pyhd3eb1b0_0 backports.shutil_get_terminal_size 1.0.0 pyhd3eb1b0_3 backports.tempfile 1.0 pyhd3eb1b0_1 backports.weakref 1.0.post1 py_1 beautifulsoup4 4.10.0 pyh06a4308_0 binaryornot 0.4.4 pyhd3eb1b0_1 bitarray 1.7.0 py39hfd63f10_1 bkcharts 0.2 py39hd43f75c_0 black 19.10b0 py_0 blas 1.0 openblas bleach 4.0.0 pyhd3eb1b0_0 blosc 1.21.0 h2f720b1_0 bokeh 2.4.1 py39hd43f75c_0 boto 2.49.0 py39hd43f75c_0 bottleneck 1.3.2 py39hfd0a847_1 brotli 1.0.9 h4de3ea5_4 brotlipy 0.7.0 py39hfd63f10_1002 brunsli 0.1 h7c1a80f_1 bzip2 1.0.8 hfd63f10_2 c-ares 1.17.1 hfd63f10_0 ca-certificates 2021.10.26 hd43f75c_2 cached-property 1.5.2 py_0 cairo 1.16.0 h81ccd62_1 certifi 2021.10.8 py39hd43f75c_0 cffi 1.14.5 py39hdced402_0 cfitsio 3.470 hd546d51_6 chardet 4.0.0 py39hd43f75c_1003 charls 2.2.0 h7c1a80f_0 charset-normalizer 2.0.4 pyhd3eb1b0_0 click 8.0.3 pyhd3eb1b0_0 cloudpickle 2.0.0 pyhd3eb1b0_0 clyent 1.2.2 py39hd43f75c_1 colorama 0.4.4 pyhd3eb1b0_0 conda 4.10.3 py39_0 conda-build 3.21.5 py39hd43f75c_0 conda-content-trust 0.1.1 pyhd3eb1b0_0 conda-env 2.6.0 hd43f75c_1 conda-pack 0.6.0 pyhd3eb1b0_0 conda-package-handling 1.7.3 py39h2f4d8fa_1 conda-repo-cli 1.0.4 pyhd3eb1b0_0 conda-token 0.3.0 pyhd3eb1b0_0 conda-verify 3.4.2 py_1 contextlib2 0.6.0.post1 pyhd3eb1b0_0 cookiecutter 1.7.2 pyhd3eb1b0_0 cryptography 3.4.7 py39hc8f1c36_0 curl 7.71.1 h8ea0f78_1 cycler 0.10.0 py39hd43f75c_0 cython 0.29.24 py39h2f4d8fa_0 cytoolz 0.11.0 py39hfd63f10_0 dask 2021.10.0 pyhd3eb1b0_0 dask-core 2021.10.0 pyhd3eb1b0_0 dataclasses 0.8 pyh6d0b6a4_7 dbus 1.13.18 h821dc26_0 debugpy 1.4.1 py39h22f4aa5_0 decorator 5.1.0 pyhd3eb1b0_0 defusedxml 0.7.1 pyhd3eb1b0_0 diff-match-patch 20200713 pyhd3eb1b0_0 distributed 2021.10.0 py39hd43f75c_0 docutils 0.17 py39hd43f75c_1 entrypoints 0.3 py39hd43f75c_0 epoxy 1.5.4 h2f4d8fa_2 et_xmlfile 1.1.0 py39hd43f75c_0 expat 2.4.1 h22f4aa5_2 fastcache 1.1.0 py39hfd63f10_0 filelock 3.3.1 pyhd3eb1b0_1 flake8 3.9.2 pyhd3eb1b0_0 flask 1.1.2 pyhd3eb1b0_0 fontconfig 2.13.1 hbe5a0c3_0 fonttools 4.25.0 pyhd3eb1b0_0 freetype 2.10.4 hbbbf32d_1 fribidi 1.0.10 hfd63f10_0 fsspec 2021.8.1 pyhd3eb1b0_0 future 0.18.2 py39hd43f75c_1 gdk-pixbuf 2.38.2 h920789f_4 get_terminal_size 1.0.0 hd43f75c_0 gettext 0.21.0 h8e1abe2_0 gevent 21.8.0 py39h2f4d8fa_1 giflib 5.2.1 hfd63f10_0 glib 2.69.1 h7cb9b0f_0 glob2 0.7 pyhd3eb1b0_0 gmp 6.2.1 h7c1a80f_1 gmpy2 2.0.8 py39h3d095b0_3 gobject-introspection 1.68.0 py39h5d90252_2 graphite2 1.3.14 h0b239d7_0 greenlet 1.1.1 py39h22f4aa5_0 gst-plugins-base 1.14.1 hfb8a71d_0 gstreamer 1.14.1 h982c5ff_0 gtk3 3.24.21 h1c650a6_2 h5py 3.1.0 py39ha894db9_0 harfbuzz 2.8.0 h905054b_0 hdf5 1.12.0 h702ddfa_1 heapdict 1.0.1 pyhd3eb1b0_0 hicolor-icon-theme 0.17 hd43f75c_2 html5lib 1.1 pyhd3eb1b0_0 icu 68.1 h7c1a80f_0 idna 3.2 pyhd3eb1b0_0 imagecodecs 2021.8.26 py39h586b9b7_0 imageio 2.9.0 pyhd3eb1b0_0 imagesize 1.2.0 pyhd3eb1b0_0 importlib-metadata 4.8.1 py39hd43f75c_0 importlib_metadata 4.8.1 hd3eb1b0_0 inflection 0.5.1 py39hd43f75c_0 iniconfig 1.1.1 pyhd3eb1b0_0 intervaltree 3.1.0 pyhd3eb1b0_0 ipykernel 6.4.1 py39hd43f75c_1 ipython 7.29.0 py39hf83f34d_0 ipython_genutils 0.2.0 pyhd3eb1b0_1 ipywidgets 7.6.5 pyhd3eb1b0_1 isort 5.9.3 pyhd3eb1b0_0 itsdangerous 2.0.1 pyhd3eb1b0_0 jbig 2.1 hfd63f10_0 jdcal 1.4.1 pyhd3eb1b0_0 jedi 0.18.0 py39hd43f75c_1 jeepney 0.7.1 pyhd3eb1b0_0 jinja2 2.11.3 pyhd3eb1b0_0 jinja2-time 0.2.0 pyhd3eb1b0_2 joblib 1.1.0 pyhd3eb1b0_0 jpeg 9d h2f4d8fa_0 json5 0.9.6 pyhd3eb1b0_0 jsonschema 3.2.0 pyhd3eb1b0_2 jupyter 1.0.0 py39hd43f75c_7 jupyter_client 6.1.12 pyhd3eb1b0_0 jupyter_console 6.4.0 pyhd3eb1b0_0 jupyter_core 4.8.1 py39hd43f75c_0 jupyter_server 1.4.1 py39hd43f75c_0 jupyterlab 3.2.1 pyhd3eb1b0_1 jupyterlab_pygments 0.1.2 py_0 jupyterlab_server 2.8.2 pyhd3eb1b0_0 jupyterlab_widgets 1.0.0 pyhd3eb1b0_1 jxrlib 1.1 hfd63f10_2 keyring 22.3.0 py39hd43f75c_0 kiwisolver 1.3.1 py39h7c1a80f_0 krb5 1.19.2 h9f0e0cd_0 lazy-object-proxy 1.6.0 py39hfd63f10_0 lcms2 2.12 h5246980_0 ld_impl_linux-aarch64 2.36.1 h0ab8de2_3 lerc 3.0 h22f4aa5_0 libaec 1.0.4 h7c1a80f_1 libarchive 3.4.2 hbc894fb_0 libcups 2.2.12 h549d06d_1 libcurl 7.71.1 h48584d0_1 libdeflate 1.7 hfd63f10_5 libedit 3.1.20210910 h2f4d8fa_0 libev 4.33 hfd63f10_1 libevent 2.1.10 hcd09bdd_2 libffi 3.3 h7c1a80f_2 libgcc-ng 10.2.0 h1234567_51 libgfortran-ng 10.2.0 h9534d94_51 libgfortran5 10.2.0 h1234567_51 libgomp 10.2.0 h1234567_51 liblief 0.10.1 h7c1a80f_1 libllvm11 11.1.0 h6c8bc22_0 libopenblas 0.3.13 hf4835c0_1 libpng 1.6.37 h8ea0f78_0 libpq 12.2 h2007d8e_0 librsvg 2.50.7 h7ed7576_0 libsodium 1.0.18 hfd63f10_0 libspatialindex 1.9.3 h7c1a80f_0 libssh2 1.9.0 hcd09bdd_1 libstdcxx-ng 10.2.0 h1234567_51 libtiff 4.2.0 he67034a_0 libtool 2.4.6 h7c1a80f_1007 libuuid 1.0.3 hfd63f10_2 libuv 1.40.0 hfd63f10_0 libwebp 1.2.0 h5bb14bb_0 libwebp-base 1.2.0 h4e544f5_0 libxcb 1.14 hfd63f10_0 libxkbcommon 1.0.1 h1897131_0 libxml2 2.9.12 he30c317_0 libxslt 1.1.34 hececbcc_0 libzopfli 1.0.3 h7c1a80f_0 llvmlite 0.37.0 py39h22f4aa5_0 locket 0.2.1 py39hd43f75c_1 lxml 4.6.3 py39h8430397_0 lz4-c 1.9.3 h7c1a80f_0 lzo 2.10 hfd63f10_4 markupsafe 1.1.1 py39hfd63f10_0 matplotlib 3.4.3 py39hd43f75c_0 matplotlib-base 3.4.3 py39h78f1600_0 matplotlib-inline 0.1.2 pyhd3eb1b0_2 mccabe 0.6.1 py39hd43f75c_1 mistune 0.8.4 py39hfd63f10_1000 mock 4.0.3 pyhd3eb1b0_0 more-itertools 8.10.0 pyhd3eb1b0_0 mpc 1.1.0 h3d095b0_1 mpfr 4.0.2 h51dc842_1 mpmath 1.2.1 py39hd43f75c_0 msgpack-python 1.0.2 py39h949e957_1 multipledispatch 0.6.0 py39hd43f75c_0 munkres 1.1.4 py_0 mypy_extensions 0.4.1 py39hd43f75c_0 navigator-updater 0.2.1 py39_0 nbclassic 0.2.6 pyhd3eb1b0_0 nbclient 0.5.3 pyhd3eb1b0_0 nbconvert 6.1.0 py39hd43f75c_0 nbformat 5.1.3 pyhd3eb1b0_0 ncurses 6.3 h2f4d8fa_1 nest-asyncio 1.5.1 pyhd3eb1b0_0 networkx 2.6.3 pyhd3eb1b0_0 ninja 1.10.2 py39h949e957_0 nltk 3.6.5 pyhd3eb1b0_0 nomkl 3.0 0 nose 1.3.7 pyhd3eb1b0_1006 notebook 6.4.5 py39hd43f75c_0 numba 0.54.1 py39h839d321_0 numexpr 2.7.3 py39hfbfe6b9_0 numpy 1.20.3 py39h6fc94f6_0 numpy-base 1.20.3 py39h6ba5a95_0 numpydoc 1.1.0 pyhd3eb1b0_1 olefile 0.46 pyhd3eb1b0_0 openblas 0.3.13 hd43f75c_1 openblas-devel 0.3.13 hd43f75c_1 openjpeg 2.4.0 hf3eb033_0 openpyxl 3.0.9 pyhd3eb1b0_0 openssl 1.1.1l h2f4d8fa_0 packaging 21.0 pyhd3eb1b0_0 pandas 1.3.4 py39h337a648_0 pandocfilters 1.4.3 py39hd43f75c_1 pango 1.45.3 hef97164_0 parso 0.8.2 pyhd3eb1b0_0 partd 1.2.0 pyhd3eb1b0_0 patchelf 0.13 h22f4aa5_0 path 16.0.0 pyhd3eb1b0_0 path.py 12.5.0 hd3eb1b0_0 pathlib2 2.3.6 py39hd43f75c_2 pathspec 0.7.0 py_0 patsy 0.5.2 py39hd43f75c_0 pcre 8.45 h22f4aa5_0 pep8 1.7.1 py39hd43f75c_0 pexpect 4.8.0 pyhd3eb1b0_3 pickleshare 0.7.5 pyhd3eb1b0_1003 pillow 8.4.0 py39hc5d9b3f_0 pip 21.2.4 py39hd43f75c_0 pixman 0.40.0 h2f4d8fa_1 pkginfo 1.7.1 py39hd43f75c_0 pluggy 0.13.1 py39hd43f75c_0 ply 3.11 py39hd43f75c_0 poyo 0.5.0 pyhd3eb1b0_0 prometheus_client 0.11.0 pyhd3eb1b0_0 prompt-toolkit 3.0.20 pyhd3eb1b0_0 prompt_toolkit 3.0.20 hd3eb1b0_0 psutil 5.8.0 py39hfd63f10_1 ptyprocess 0.7.0 pyhd3eb1b0_2 py 1.10.0 pyhd3eb1b0_0 py-lief 0.10.1 py39h7c1a80f_1 pycodestyle 2.7.0 pyhd3eb1b0_0 pycosat 0.6.3 py39hfd63f10_2 pycparser 2.20 py_2 pycurl 7.44.1 py39ha9ffb65_1 pydocstyle 6.1.1 pyhd3eb1b0_0 pyerfa 2.0.0 py39h2f4d8fa_0 pyflakes 2.3.1 pyhd3eb1b0_0 pygments 2.10.0 pyhd3eb1b0_0 pyjwt 2.1.0 py39hd43f75c_0 pylint 2.7.4 py39hd43f75c_1 pyls-spyder 0.4.0 pyhd3eb1b0_0 pyodbc 4.0.30 py39h7c1a80f_0 pyopenssl 21.0.0 pyhd3eb1b0_1 pyparsing 3.0.4 pyhd3eb1b0_0 pyqt 5.15.2 py39h22f4aa5_0 pyqt5-sip 4.19.25 pypi_0 pypi pyqtchart 5.15.2 pypi_0 pypi pyqtwebengine 5.15.2 pypi_0 pypi pyrsistent 0.18.0 py39h2f4d8fa_0 pysocks 1.7.1 py39hd43f75c_0 pytables 3.6.1 py39he7eab4e_1 pytest 6.2.3 py39hd43f75c_2 python 3.9.7 hc137634_1 python-dateutil 2.8.2 pyhd3eb1b0_0 python-libarchive-c 2.9 pyhd3eb1b0_1 python-lsp-black 1.0.0 pyhd3eb1b0_0 python-lsp-jsonrpc 1.0.0 pyhd3eb1b0_0 python-lsp-server 1.2.4 pyhd3eb1b0_0 python-slugify 5.0.2 pyhd3eb1b0_0 pytz 2021.3 pyhd3eb1b0_0 pywavelets 1.1.1 py39hfd0a847_4 pyxdg 0.27 pyhd3eb1b0_0 pyyaml 5.4.1 py39hfd63f10_2 pyzmq 20.0.0 py39h7c1a80f_1 qdarkstyle 3.0.2 pyhd3eb1b0_0 qstylizer 0.1.10 pyhd3eb1b0_0 qt 5.15.2 h4236ef2_3 qtawesome 1.0.2 pyhd3eb1b0_0 qtconsole 5.1.1 pyhd3eb1b0_0 qtpy 1.10.0 pyhd3eb1b0_0 readline 8.1 hfd63f10_0 regex 2021.8.3 py39h2f4d8fa_0 requests 2.26.0 pyhd3eb1b0_0 rope 0.19.0 pyhd3eb1b0_0 rtree 0.9.7 py39hd43f75c_1 ruamel_yaml 0.15.80 py39hfd63f10_0 scikit-image 0.18.3 py39h839d321_0 scikit-learn 0.24.2 py39h839d321_1 scipy 1.7.1 py39ha4eada7_2 seaborn 0.11.2 pyhd3eb1b0_0 secretstorage 3.3.1 py39hd43f75c_0 send2trash 1.8.0 pyhd3eb1b0_1 setuptools 58.0.4 py39hd43f75c_0 simplegeneric 0.8.1 py39hd43f75c_2 singledispatch 3.7.0 pyhd3eb1b0_1001 sip 4.19.25 py39h7c1a80f_0 six 1.16.0 pyhd3eb1b0_0 snappy 1.1.8 h7c1a80f_0 sniffio 1.2.0 py39hd43f75c_1 snowballstemmer 2.1.0 pyhd3eb1b0_0 sortedcollections 2.1.0 pyhd3eb1b0_0 sortedcontainers 2.4.0 pyhd3eb1b0_0 soupsieve 2.2.1 pyhd3eb1b0_0 sphinx 4.2.0 pyhd3eb1b0_1 sphinxcontrib 1.0 py39hd43f75c_1 sphinxcontrib-applehelp 1.0.2 pyhd3eb1b0_0 sphinxcontrib-devhelp 1.0.2 pyhd3eb1b0_0 sphinxcontrib-htmlhelp 2.0.0 pyhd3eb1b0_0 sphinxcontrib-jsmath 1.0.1 pyhd3eb1b0_0 sphinxcontrib-qthelp 1.0.3 pyhd3eb1b0_0 sphinxcontrib-serializinghtml 1.1.5 pyhd3eb1b0_0 sphinxcontrib-websupport 1.2.4 py_0 spyder 5.1.5 py39hd43f75c_0 spyder-kernels 2.1.3 py39hd43f75c_0 sqlalchemy 1.3.23 py39hfd63f10_0 sqlite 3.36.0 h6632b73_0 statsmodels 0.13.0 py39h2f4d8fa_0 sympy 1.9 py39hd43f75c_0 tbb 2021.4.0 h59a28a9_0 tbb4py 2021.4.0 py39h59a28a9_0 tblib 1.7.0 pyhd3eb1b0_0 terminado 0.9.4 py39hd43f75c_0 testpath 0.5.0 pyhd3eb1b0_0 text-unidecode 1.3 pyhd3eb1b0_0 textdistance 4.2.1 pyhd3eb1b0_0 threadpoolctl 2.2.0 pyh0d69192_0 three-merge 0.1.1 pyhd3eb1b0_0 tifffile 2021.7.2 pyhd3eb1b0_2 tinycss 0.4 pyhd3eb1b0_1002 tk 8.6.11 h241ca14_0 toml 0.10.2 pyhd3eb1b0_0 toolz 0.11.1 pyhd3eb1b0_0 tornado 6.1 py39hfd63f10_0 tqdm 4.62.3 pyhd3eb1b0_1 traitlets 5.1.0 pyhd3eb1b0_0 typed-ast 1.4.3 py39h2f4d8fa_1 typing_extensions 3.10.0.2 pyh06a4308_0 tzdata 2021e hda174b7_0 ujson 4.0.2 py39h7c1a80f_0 unicodecsv 0.14.1 py39hd43f75c_0 unidecode 1.2.0 pyhd3eb1b0_0 unixodbc 2.3.9 hfd63f10_0 urllib3 1.26.7 pyhd3eb1b0_0 watchdog 1.0.2 py39hd43f75c_1 wcwidth 0.2.5 pyhd3eb1b0_0 webencodings 0.5.1 py39hd43f75c_1 werkzeug 2.0.2 pyhd3eb1b0_0 wheel 0.37.0 pyhd3eb1b0_1 whichcraft 0.6.1 pyhd3eb1b0_0 widgetsnbextension 3.5.1 py39hd43f75c_0 wrapt 1.12.1 py39hfd63f10_1 wurlitzer 2.0.1 py39hd43f75c_0 xlrd 2.0.1 pyhd3eb1b0_0 xlsxwriter 3.0.1 pyhd3eb1b0_0 xlwt 1.3.0 py39hd43f75c_0 xmltodict 0.12.0 pyhd3eb1b0_0 xz 5.2.5 hfd63f10_1 yaml 0.1.7 hfd63f10_4 yapf 0.31.0 pyhd3eb1b0_0 zeromq 4.3.4 h7c1a80f_0 zict 2.0.0 pyhd3eb1b0_0 zipp 3.6.0 pyhd3eb1b0_0 zlib 1.2.11 hfd63f10_5 zope 1.0 py39hd43f75c_1 zope.event 4.5.0 py39hd43f75c_0 zope.interface 5.4.0 py39h2f4d8fa_0 zstd 1.4.9 h20642d3_2
- conda create --name(-n) <package name> python=3.x : Create an anaconda virtual environment with "package name" and install python 3.x. If possible, it is recommended to set a naming convention for the package name so that the installed version of Python and its important purpose are known. The virtual environment name created in this way can be changed later if necessary.
- conda activate package name : Enter the virtual environment of the package name.
Changed Python Environment
The following are Python commands and versions without anaconda environment applied.
root@spypiggy-desktop:~# python Python 2.7.17 (default, Feb 27 2021, 15:10:58) [GCC 7.5.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. root@spypiggy-desktop:~# python3 Python 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0] on linux Type "help", "copyright", "credits" or "license" for more information.
JetPack 4.6 uses Python 2.7 and 3.6.
However, in the anaconda environment, the default Python is changed to 3.9. Of course, this version can use the new Python version while creating a new anaconda virtual environment.
When the anaconda environment variable is applied, both python and python3 commands run Python 3.9.
spypiggy@spypiggy-desktop:~$ python Python 3.9.7 (default, Sep 16 2021, 16:31:42) [GCC 10.2.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> spypiggy@spypiggy-desktop:~$ python3 Python 3.9.7 (default, Sep 16 2021, 16:31:42) [GCC 10.2.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information.
But this version of Python doesn't mean much. This is because we will use a new version of Python by creating a new anaconda virtual environment.
Creating a new conda virtual environment
JetPack 4.6 comes with Python 3.6 installed as we saw earlier. And Anaconda installs Python 3.9 by default. I'm going to create a virtual environment using Python 3.8.
spypiggy@spypiggy-desktop:~$ conda create -n py_38 python=3.8.12 Collecting package metadata (current_repodata.json): done Solving environment: done ## Package Plan ## environment location: /home/spypiggy/anaconda3/envs/py_38 added / updated specs: - python=3.8.12 The following packages will be downloaded: package | build ---------------------------|----------------- certifi-2021.10.8 | py38hd43f75c_2 143 KB pip-21.2.4 | py38hd43f75c_0 1.8 MB python-3.8.12 | hc137634_0 9.6 MB setuptools-58.0.4 | py38hd43f75c_0 763 KB sqlite-3.37.2 | h6632b73_0 1.3 MB ------------------------------------------------------------ Total: 13.5 MB The following NEW packages will be INSTALLED: _libgcc_mutex pkgs/main/linux-aarch64::_libgcc_mutex-0.1-main _openmp_mutex pkgs/main/linux-aarch64::_openmp_mutex-5.1-51_gnu ca-certificates pkgs/main/linux-aarch64::ca-certificates-2021.10.26-hd43f75c_2 certifi pkgs/main/linux-aarch64::certifi-2021.10.8-py38hd43f75c_2 ld_impl_linux-aar~ pkgs/main/linux-aarch64::ld_impl_linux-aarch64-2.36.1-h0ab8de2_3 libffi pkgs/main/linux-aarch64::libffi-3.3-h7c1a80f_2 libgcc-ng pkgs/main/linux-aarch64::libgcc-ng-10.2.0-h1234567_51 libgomp pkgs/main/linux-aarch64::libgomp-10.2.0-h1234567_51 libstdcxx-ng pkgs/main/linux-aarch64::libstdcxx-ng-10.2.0-h1234567_51 ncurses pkgs/main/linux-aarch64::ncurses-6.3-h2f4d8fa_2 openssl pkgs/main/linux-aarch64::openssl-1.1.1m-h2f4d8fa_0 pip pkgs/main/linux-aarch64::pip-21.2.4-py38hd43f75c_0 python pkgs/main/linux-aarch64::python-3.8.12-hc137634_0 readline pkgs/main/linux-aarch64::readline-8.1.2-h2f4d8fa_1 setuptools pkgs/main/linux-aarch64::setuptools-58.0.4-py38hd43f75c_0 sqlite pkgs/main/linux-aarch64::sqlite-3.37.2-h6632b73_0 tk pkgs/main/linux-aarch64::tk-8.6.11-h241ca14_0 wheel pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0 xz pkgs/main/linux-aarch64::xz-5.2.5-hfd63f10_1 zlib pkgs/main/linux-aarch64::zlib-1.2.11-hfd63f10_5 Proceed ([y]/n)? y Downloading and Extracting Packages pip-21.2.4 | 1.8 MB | ##################################################################################################### | 100% sqlite-3.37.2 | 1.3 MB | ##################################################################################################### | 100% certifi-2021.10.8 | 143 KB | ##################################################################################################### | 100% setuptools-58.0.4 | 763 KB | ##################################################################################################### | 100% python-3.8.12 | 9.6 MB | ##################################################################################################### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done # # To activate this environment, use # # $ conda activate py_38 # # To deactivate an active environment, use # # $ conda deactivate
You can see that packages such as pip and sqlite are installed together with Python 3.8.12. Packages included in Anaconda can be added with the conda install command, and packages not included can be added with the pip install command.
You can check the newly created anaconda virtual environment with the conda env list command.
spypiggy@spypiggy-desktop:~$ conda env list # conda environments: # base * /home/spypiggy/anaconda3 py_38 /home/spypiggy/anaconda3/envs/py_38
Wrapping Up
Machine learning packages each require their own version of Python and packages. When multiple packages are run on one Xavier NX, package version problems inevitably occur. The best way to solve this problem is to use anaconda (anaconda). Anaconda has the advantage of specifying the Python version at the time of creating a virtual environment, so various Python versions can be run on a single host. In the next article, we will install various TensorFlow and PyTorch in the Anaconda environment.