安装Miniconda@FreeBSD13

近几年在学习和使用AI框架的时候,时时刻刻在想着如何在FreeBSD下进行训练和推理部署,可惜一直没有如愿。

近几天在调试大模型的一些项目时,尝试将飞桨、torch和tensorflow装了个遍,可惜都没有成功。机缘巧合下,看到freebsd-stable-diffusion这个项目,了解到有linux-miniconda-installer这个软件包,并通过学习它而学到如何在FreeBSD下安装任意版本的Miniconda。

本文档将两种安装方法都发布出来。 在FreeBSD下安装Miniconda需要用到linux兼容服务,具体linux兼容服务参考手册:Chapter 12. Linux Binary Compatibility | FreeBSD Documentation Portal

使用FreeBSD 线程的pkg安装miniconda

先安装miniconda安装器

在root账户下安装,通过pkg search miniconda我们可以只通过关键字就查到这个安装包的具体名字。

pkg search miniconda

pkg install linux-miniconda-installer

运行安装程序

miniconda-installer 

This miniconda requires python3.8.  Install lang/python38 and try again.

发现需要python3.8,这个miniconda版本也太低了吧。我就不不再演示了,有需要的朋友可以使用这个方法安装。

手动安装任意版本Miniconda

可以下载任意版本安装,比如从清华源https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/找版本。

下载miniconda安装软件

自己下个最新版本的miniconda安装软件:https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh

使用wget下载

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh

设置和配置环境

设置md5sum链接(个人认为不必要):

mkdir -p ~/bin
ln -sf /sbin/md5 ~/bin/md5sum

将linux的md5sum放在路径第一位:

export PATH=/compat/linux/usr/bin:$PATH

设置和启动linux兼容服务,需要在root账户下执行

kldload linux64
pkg install linux-miniconda-installer # 这个可选
sysrc linux_enable="YES"
service linux start

 具体linux兼容服务参考手册:Chapter 12. Linux Binary Compatibility | FreeBSD Documentation Portal

安装

执行兼容linux命令安装,因为我们的bash不是默认的FreeBSD /bin下的,而是/compat/linux/bin/下的。 后面跟下载的Miniconda文件名。 -u参数是覆盖安装,即如果指定的安装目录存在,则不退出,而是继续覆盖安装。

执行命令:

 /compat/linux/bin/bash Miniconda3-py310_23.9.0-0-Linux-x86_64.sh -u

安装过程中提示如下,这里选默认选项no

If you'd prefer that conda's base environment not be activated on startup,
   run the following command when conda is activated:

conda config --set auto_activate_base false

You can undo this by running `conda init --reverse $SHELL`? [yes|no]

 安装好后,显示:

You have chosen to not have conda modify your shell scripts at all.
To activate conda's base environment in your current shell session:

eval "$(/home/skywalk/miniconda3/bin/conda shell.YOUR_SHELL_NAME hook)" 

To install conda's shell functions for easier access, first activate, then:

conda init

 激活conda环境

按照一篇文档里写的:

# BASE_PATH为安装路径
bash
source ${BASE_PATH}/etc/profile.d/conda.sh
conda activate

 我的激活方法更简单方便

source ~/miniconda3/bin/activate

 现在miniconda安装完成,环境也激活了!

测试

安装pytorch试试

conda install pytorch

 哦也,没设置conda镜像也挺快!测试:

python                                         
Python 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0] on linux                       
Type "help", "copyright", "credits" or "license" for more information.                   
import pytorch                                                                           
>>> import pytorch                                                                       
Traceback (most recent call last):                                                       
  File "<stdin>", line 1, in <module>                                                    
ModuleNotFoundError: No module named 'pytorch'                                           
>>> import torch                                                                         
x = torch.randn(>>> x = torch.randn((2,3))                                               
>>> y = x+1                                                                              
>>> y                                                                                    
tensor([[0.3041, 1.6502, 0.2174],                                                        
        [2.3316, 0.0055, 1.1459]])                                                       

      

测试通过!

安装飞桨试试

conda install paddlepaddle==2.6.1 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/

 测试通过:

>>> import paddle                                                                        
>>> paddle.utils.run_check()
Running verify PaddlePaddle program ... 
I0419 12:19:17.929461 78565 program_interpreter.cc:212] New Executor is Running.
I0419 12:19:18.267753 78565 interpreter_util.cc:624] Standalone Executor is Used.
PaddlePaddle works well on 1 CPU.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
>>> 

今天很高兴啊,这样不出意外的话,几乎所有的AI框架都可以在FreeBSD系统下安装了!乌拉!

调试

安装Miniconda时报错:

[/home/skywalk/miniconda3] >>>
PREFIX=/home/skywalk/miniconda3
md5sum: -: No such file or directory

解决方法:

mkdir -p ~/bin
ln -sf /sbin/md5 ~/bin/md5sum

问题还是没有解决

安装时报错 md5sum: -: No such file or directory

找到问题了,前面方法无法解决这个问题,真正的解决方法是:要将linux那边的md5sum放到路径第一位才行

export PATH=/compat/linux/bin:$PATH

相关推荐

  1. Centos 7 安装 Node.js v16.13.1

    2024-04-21 19:48:02       43 阅读
  2. win10、win11安装pytorch(可用)

    2024-04-21 19:48:02       52 阅读
  3. Ubuntu20.04安装cuda12.11

    2024-04-21 19:48:02       67 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-21 19:48:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-21 19:48:02       101 阅读
  3. 在Django里面运行非项目文件

    2024-04-21 19:48:02       82 阅读
  4. Python语言-面向对象

    2024-04-21 19:48:02       91 阅读

热门阅读

  1. oracle快速定位数据库瓶颈

    2024-04-21 19:48:02       29 阅读
  2. Oracle中的CASE WHEN语句使用详解与实例

    2024-04-21 19:48:02       35 阅读
  3. OracleDay01

    2024-04-21 19:48:02       37 阅读
  4. FFmpeg:自实现ijkplayer播放器--11音视频同步

    2024-04-21 19:48:02       34 阅读
  5. 在Rust中使用ini配置文件

    2024-04-21 19:48:02       35 阅读
  6. Rust开发笔记 | Rust的交互式Shell

    2024-04-21 19:48:02       39 阅读
  7. NVIC简介

    2024-04-21 19:48:02       34 阅读
  8. Python与设计模式之适配器的使用方法

    2024-04-21 19:48:02       31 阅读