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 run the command: wget https://repo.anaconda.com/miniconda/Miniconda3-py310_24.5.0-0-Linux-x86_64.sh
    • After the download completes, continue with: bash Miniconda3-py310_24.5.0-0-Linux-x86_64.sh
    • Some agreements or prompts will appear; enter yes or press Enter to proceed.
    • Once the installation is complete, it is recommended to add it to the global environment for easy use of the conda command. By default, it may be installed in /root/miniconda3. If so, run: cp /root/miniconda3/bin/conda /usr/bin/conda. Replace the path if it is different.
    • Close the terminal window and reopen it for the environment to take effect.
  2. Create a virtual environment using python3.10 by running: conda create -n videotrans python=3.10. If prompted, enter yes and press Enter.

  3. Activate the virtual environment with: conda activate videotrans

  4. Create an empty folder for deploying the source code. Assuming you have created /data/pyvideo, navigate into it and pull the source code from GitHub with: git clone https://github.com/jianchang512/pyvideotrans .

  5. Install dependencies by running: pip install -r requirements.txt. Wait for the process to complete.

  6. Install ffmpeg: on CentOS, run yum install ffmpeg; on Ubuntu, run apt-get install ffmpeg.

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

Possible Errors During Installation

  1. Failed to Install the samplerate Module You might encounter an error related to samplerate, a pip module that requires compiling source code. This can easily fail due to different system versions and environments. The error code may look like this:

    -- 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

    Or the error might be:

    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 an upgrade. For CentOS systems, run the following commands:

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

    After that, run:

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

    Then re-run pip install -r requirements.txt.

  2. Pip Mirror Source Issues If pip installation is very slow, consider switching to the Alibaba Cloud mirror source to speed it up. Run the following two commands to switch to the Alibaba 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 Alibaba Cloud mirror might lack some module versions. If you encounter this issue and want to switch back to the official default source, navigate to cd ~/.config/pip, open the pip.conf file, delete its contents, and the official source will be restored.

  3. Using CUDA Acceleration Run the following commands separately:

    Example

    pip3 uninstall -y torch torchaudio
    
    pip3 install torch torchaudio --index-url https://download.pytorch.org/whl/cu126
    
    pip3 install nvidia-cublas-cu12 nvidia-cudnn-cu12