Skip to content

Linux Source Code Deployment

  1. On Linux, it's recommended to use miniconda for installation and deployment to avoid many environment issues.
  • First, install miniconda. Open the terminal and execute the command wget https://repo.anaconda.com/miniconda/Miniconda3-py310_24.5.0-0-Linux-x86_64.sh
  • Wait for the download to complete, then execute bash Miniconda3-py310_24.5.0-0-Linux-x86_64.sh
  • Next, some agreements or instructions will be displayed. You need to input yes or press Enter to continue.
  • After the prompt is complete, it is recommended to add it to the global environment so that you can use the short command conda. It may be installed in /root/miniconda3 by default. If this is the case, please execute cp /root/miniconda3/bin/conda /usr/bin/conda. If it's in a different location, please replace it accordingly.
  • Close the terminal window and reopen it for the environment to take effect.
  1. Create a virtual environment using python3.10, execute the command conda create -n videotrans python=3.10. If prompted, input yes and press Enter.
  2. Activate the virtual environment, execute the command conda activate videotrans
  3. Create an empty folder for deploying the source code. Assuming /data/pyvideo has been created, enter the folder and pull the source code from GitHub by executing the command git clone https://github.com/jianchang512/pyvideotrans .
  4. Install dependencies, execute the command pip install -r requirements.txt, and wait for the prompt to complete.
  5. Install ffmpeg. On CentOS, execute yum install ffmpeg; on Ubuntu, execute apt-get install ffmpeg
  6. If there are no errors, execute python sp.py to open the software and python api.py to run the API service.

Potential Errors During Installation

  1. samplerate module installation failure You may encounter an error containing the word samplerate. This is a pip module that requires compiling the source code for installation. It's very easy to fail to compile and cause errors on different system versions and environments. The error code is similar to the one below:
-- Build files have been written to: /tmp/pip-install-0355nvxe/samplerate_f6c17d8f7ab94e0b9f8d7e16697c1ab3/build/temp.linux-x86_64-cpython-310/samplerate
  [ 14%] Building C object _deps/libsamplerate-build/src/CMakeFiles/samplerate.dir/samplerate.c.o
  [ 28%] Building C object _deps/libsamplerate-build/src/CMakeFiles/samplerate.dir/src_linear.c.o
  [ 42%] Building C object _deps/libsamplerate-build/src/CMakeFiles/samplerate.dir/src_sinc.c.o
  [ 57%] Building C object _deps/libsamplerate-build/src/CMakeFiles/samplerate.dir/src_zoh.c.o
  [ 71%] Linking C static library libsamplerate.a
  [ 71%] Built target samplerate
  [ 85%] Building CXX object CMakeFiles/python-samplerate.dir/src/samplerate.cpp.o
  c++: error: unrecognized command line option ‘-std=c++14’
  gmake[2]: *** [CMakeFiles/python-samplerate.dir/src/samplerate.cpp.o] Error 1
  gmake[1]: *** [CMakeFiles/python-samplerate.dir/all] Error 2
  gmake: *** [all] Error 2

The error might also look like this:

centos7 ImportError: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /data2/conda/envs/pyvideo/lib/python3.10/site-packages/shiboken6/Shiboken.abi3.so)

This indicates that the c++/cmake version is too low and needs to be upgraded. Execute the following commands. For CentOS series, execute the following commands respectively:

yum updateyum clean allyum remove devtoolset-8yum update libstdc++yum install devtoolset-8 devtoolset-9-libstdc++-devel scl-utils

After execution, continue with:

export CFLAGS="-fPIC"export CXXFLAGS="-fPIC"

Then re-execute pip install -r requirements.txt

  1. pip mirror source issues

If pip installation is very slow, consider switching to the Aliyun mirror source to speed up the installation. Execute the following two commands to switch the pip mirror to the Aliyun mirror, then reinstall:

```

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set install.trusted-host mirrors.aliyun.com

```

The Aliyun mirror source may lack some module versions. If you encounter this problem and want to switch back to the official default source, execute cd ~/.config/pip, open the pip.conf file, and delete the contents to restore the official source.

  1. Using CUDA acceleration, execute the following:

    pip uninstall -y torch torchaudio

    pip install torch==2.2.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu118

    pip install nvidia-cublas-cu11 nvidia-cudnn-cu11