Skip to content

Linux Source Code Deployment

  1. It is recommended to use miniconda for installation and deployment on Linux 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
    • After the download is complete, execute bash Miniconda3-py310_24.5.0-0-Linux-x86_64.sh
    • Next, some agreements or guides will be displayed, you need to enter 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. By default, it may be installed under /root/miniconda3. If it is this command, please execute cp /root/miniconda3/bin/conda /usr/bin/conda. If it is in another location, please replace it yourself.
    • Close the terminal window and reopen it for the environment to take effect.
  2. Create a virtual environment using python3.10 and execute the command conda create -n videotrans python=3.10. If prompted, enter yes and press Enter.

  3. Activate the virtual environment and execute the command conda activate videotrans

  4. 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. Execute the command git clone https://github.com/jianchang512/pyvideotrans .

  5. Install dependencies and execute the command pip install -r requirements.txt, waiting for the prompt to complete.

  6. Install ffmpeg. Under CentOS, execute yum install ffmpeg. Under Ubuntu, execute apt-get install ffmpeg

  7. If there are no errors, execute python sp.py to open the software and execute python api.py to run the API service.

Possible errors during installation

  1. samplerate module installation failed

You may encounter an error that includes the word samplerate. This is a pip module that needs to be installed by compiling the source code. It is very easy to fail during compilation and cause errors in different system versions and environments. The error code is similar to the following:

-- 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 may also be as follows:

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 situation indicates that the c++/cmake version is too low and needs to be upgraded. Next, execute the following commands. If it is a CentOS series, execute the following commands separately:

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

After execution, continue to execute:

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

Then re-execute pip install -r requirements.txt

  1. pip mirror source problem

If pip installation is very slow, you can 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, and 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 be missing 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, delete the content inside, and the official source will be restored.

  1. Use CUDA acceleration, execute separately
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