Skip to content

Linux Source Code Deployment

  1. It is recommended to use miniconda on Linux for installation and deployment, which can 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, continue to 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. The default may be installed under /root/miniconda3. If this is the 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, execute the command conda create -n videotrans python=3.10. If prompted to enter, enter yes and then press Enter.

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

  4. Create an empty folder for deploying the source code. Assuming /data/pyvideo has been created, enter this folder, pull the source code from GitHub, and execute the command git clone https://github.com/jianchang512/pyvideotrans .

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

  6. Install ffmpeg, execute yum install ffmpeg under centos, and execute apt-get install ffmpeg under ubuntu.

  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 including the word samplerate. This is a pip module that needs to be installed by compiling the source code. It is very easy to fail to compile 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 the centos series, execute them 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 Alibaba Cloud mirror source to speed up the installation. Execute the following 2 commands to switch the pip mirror to the Alibaba 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 Alibaba Cloud mirror source may lack the version of some modules. 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 you can restore the official source.

  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