install monkyocr - zhongguogu/Linux GitHub Wiki
` sudo apt update
sudo apt install nvidia-driver-535 # 535
下载anaconda
wget https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh
conda create -n MonkeyOCR python=3.10
conda activate MonkeyOCR
git clone https://github.com/Yuliang-Liu/MonkeyOCR.git //如果下载不了,可以本地下载
cd MonkeyOCR
` ERROR: Operation cancelled by user (MonkeyOCR) ubuntu@10-60-51-1:~/project/MonkeyOCR-main$ pip install flash-attn==2.7.4.post1 --no-build-isolation -i https://pypi.tuna.tsinghua.edu.cn/simple Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting flash-attn==2.7.4.post1 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/11/34/9bf60e736ed7bbe15055ac2dab48ec67d9dbd088d2b4ae318fd77190ab4e/flash_attn-2.7.4.post1.tar.gz (6.0 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.0/6.0 MB 28.8 MB/s eta 0:00:00 Preparing metadata (setup.py) ... error error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [19 lines of output] /tmp/pip-install-xmjmyejk/flash-attn_883f013ce0da43608d5bedd0669881f3/setup.py:106: UserWarning: flash_attn was requested, but nvcc was not found. Are you sure your environment has nvcc available? If you're installing within a container from https://hub.docker.com/r/pytorch/pytorch, only images whose names contain 'devel' will provide nvcc. warnings.warn( Traceback (most recent call last): File "", line 2, in File "", line 35, in File "/tmp/pip-install-xmjmyejk/flash-attn_883f013ce0da43608d5bedd0669881f3/setup.py", line 198, in CUDAExtension( File "/home/ubuntu/anaconda3/envs/MonkeyOCR/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1078, in CUDAExtension library_dirs += library_paths(cuda=True) File "/home/ubuntu/anaconda3/envs/MonkeyOCR/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1209, in library_paths if (not os.path.exists(_join_cuda_home(lib_dir)) and File "/home/ubuntu/anaconda3/envs/MonkeyOCR/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 2416, in _join_cuda_home raise OSError('CUDA_HOME environment variable is not set. ' OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.
torch.__version__ = 2.5.1+cu124
`
执行python demo/demo_gradio.py
WARNING
AutoInstall will run now for 'dill' but this feature will be removed in the future.
Recommend fixes are to train a new model using the latest 'doclayout_yolo' package or to run a command with an official YOLOv8 model, i.e. 'yolo predict model=yolov8n.pt'
requirements: Ultralytics requirement ['dill'] not found, attempting AutoUpdate...
你遇到的警告信息表明,doclayout_yolo 模型需要 dill 库,但这个库不在它的标准依赖列表中。Ultralytics 框架正在自动尝试安装这个缺失的依赖,但这是一个临时解决方案,未来版本可能会移除这种自动安装的功能。 解决方案 pip install dill -i https://pypi.tuna.tsinghua.edu.cn/simple
- 安装 CUDA 开发工具包 首先需要安装 CUDA Toolkit:
bash
sudo apt install nvidia-cuda-toolkit
nvcc --version
Install pytorch, see https://pytorch.org/get-started/previous-versions/ for your cuda version
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install . -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install huggingface_hub -i https://pypi.tuna.tsinghua.edu.cn/simple
python download_model.py
pip install modelscope -i https://pypi.tuna.tsinghua.edu.cn/simple
python download_model.py -t modelscope
pip install gradio==5.23.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install pdf2image==1.17.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
sudo apt-get update
sudo apt-get install poppler-utils #依赖poppler
`
1、安装NVIDIA 方法 1:使用 Ubuntu 软件源安装 添加官方 NVIDIA 驱动 PPA:
bash sudo apt update sudo apt install nvidia-driver-535 # 535是当前最新的稳定版本,可能需要根据你的显卡兼容性选择其他版本
2、安装conda ubuntu@10-60-51-1:~/software$ wget https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh --2025-06-11 09:26:58-- https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh Resolving repo.anaconda.com (repo.anaconda.com)... 100.65.138.175 Connecting to repo.anaconda.com (repo.anaconda.com)|100.65.138.175|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1056829859 (1008M) [application/octet-stream] Saving to: ‘Anaconda3-2024.06-1-Linux-x86_64.sh’
Anaconda3-2024.06-1-Linux-x86_64.sh 100%[=================================================================================================================================================================>] 1008M 2.69MB/s in 5m 42s
2025-06-11 09:32:41 (2.95 MB/s) - ‘Anaconda3-2024.06-1-Linux-x86_64.sh’ saved [1056829859/1056829859]
删除 404/无效的 channel 全部换成清华或中科大等完善的国内镜像,尤其是 main/free/r/msys2/cloud 不要有 repo.anaconda.com 和 anaconda/cloud/pytorch 这种不存在的路径 清理缓存再试 如还有问题,把 conda config --show channels 的输出发出来
(base) ubuntu@10-60-51-1:~$ conda config --show channels channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- defaults 如何删除defaults 你可以用以下命令删除 conda 配置中的 defaults 源:
bash conda config --remove channels defaults