.whl文件

本文主要介绍了.whl文件的定义,怎么安装.whl文件(离线,在线)。

怎么查看cuda的版本,以及如何安装相应版本的cuda(本地电脑,超算上)

以及如何创建.whl文件

.whl文件的定义

Documentation about compression file formats:

Learn about Compression File Formats and APIs that can open and create archive files

Documentation about WHL file:

WHL File Format - Python Wheel Package File

A WHL (Wheel) file is a distribution package file saved in Python's wheel format. It is a standard format installation of Python distributions andcontains all the files and metadata required for installation . The WHL file also contains information about the Python versions and platforms supported by this wheel file. Similar to an MSI setup file, WHL file format is a ready-to-install format that allows running the installation package without building the source distribution.

.whl 文件是 Python 的一种打包格式,全称为 Wheel 文件。​它是一种预编译的二进制分发包,旨在加快和简化 Python 包的安装过程。

.whl 文件本质上是一个 ZIP 压缩包,内部包含了 Python 包的所有必要文件和元数据。​与传统的源代码分发包(如 .tar.gz)不同,Wheel 文件不需要在安装时进行编译,因此安装速度更快,过程更简便。​Wheel 文件可以针对不同的操作系统、Python 版本和 CPU 架构进行构建,确保在各种环境下的兼容性。​适合在网络受限或无法访问 PyPI 的环境中进行离线安装。

WHL file format is a ZIP (.zip) archive that contains all the installation files and metadata required by installers for installation of a package. These WHL files can be extracted using unzip option or standard decompression software applications such as WinZIP and WinRAR.

A WHL file is named as per the following convention.

复制代码
{dist}-{version}(-{build})?-{python}-{abi}-{platform}.whl

An example of the WHL file name is as follow.

复制代码
cryptography-2.9.2-cp35-abi3-macosx_10_9_x86_64.whl
  • cryptography is the package name.
  • 2.9.2 is the package version of cryptography. A version is a PEP 440-compliant string such as 2.9.2, 3.4, or 3.9.0.a3.
  • cp35 is the Python tag and denotes the Python implementation and version that the wheel demands.(表示python版本)
  • abi3 is the ABI tag. ABI stands for application binary interface.
  • macosx_10_9_x86_64 is the platform tag, which happens to be quite a mouthful.

比如说github上: state-spaces/mamba: Mamba SSM architecture

the core Mamba package:

怎么安装.whl文件

使用 pip 工具可以方便地安装 .whl 文件

复制代码
pip install 包名.whl

如果已经下载了 .whl 文件,只需将命令中的 包名.whl 替换为实际的文件名即可。​(离线安装)

在安装时,确保所使用的 .whl 文件与当前的 Python 版本和操作系统兼容。​

就比如说安装这个mamba_ssm包的时候,可以使用命令

复制代码
pip install mamba_ssm==1.0.1

或者先把相应的包下载到本地,cd到该包所在的目录下,然后输入命令:

复制代码
pip install mamba_ssm-1.0.1+cu118torch1.13cxx11abiFALSE-cp39-cp39-linux_x86_64.whl
  • cxx11abi:指 C++11 ABI,这是 C++ 的一个二进制兼容标准。

  • FALSE:表示该 wheel(预编译的二进制包)是在不启用新 C++11 ABI 的情况下编译的。

  • cxx11abiFALSE:使用旧版 ABI(兼容性更好,适合较旧的系统或与其他库链接时避免冲突)。

  • cxx11abiTRUE:使用新版 C++11 ABI(可能带来性能改进,但需要环境支持)。

怎么查看cuda的版本

cu指的是cuda版本,可以输入以下命令查看cuda的版本:

复制代码
nvcc --version

电脑可以更新cuda的版本的,可以输入以下命令查看电脑最高支持的cuda版本

复制代码
nvidia-smi

可以看到我的电脑支持的cuda最高的版本号是12.3。

如果是在超算上,可以使用以下命令查看支持的cuda版本号:

复制代码
module avail

可以看到这个超算支持的cuda版本号有11.8 12.0 12.1 12.2 12.4 12.6 12.8

安装相应版本的cuda

如果你正好需要cuda12.5版本的,那可以将cuda12.5版本的下载到自己的超算账号上。

首先在官网上找到对应的cuda版本

看到下面的命令了吧?

输入命令:

复制代码
wget https://developer.download.nvidia.com/compute/cuda/12.5.0/local_installers/cuda_12.5.0_555.42.02_linux.run

chmod +x cuda_12.5.0_555.42.02_linux.run

./cuda_12.5.0_555.42.02_linux.run --silent --toolkit --samples --installpath=/data/home/
sczc338/run/soft/cuda12.5
  1. chmod - 改变文件权限的命令

  2. +x - 添加可执行权限

  3. cuda_12.5.0_555.42.02_linux.run - CUDA安装脚本文件名

这条命令给名为cuda_11.7.0_515.43.04_linux.run的文件添加可执行权限,使其能够被系统执行。这是必要的,因为下载的安装脚本默认可能没有执行权限。

  1. ./cuda_12.5.0_555.42.02_linux.run - 执行当前目录下的CUDA安装脚本

  2. --silent - 以静默模式安装,不显示图形界面,减少用户交互

  3. --toolkit - 安装CUDA Toolkit(核心组件)

  4. --samples - 安装CUDA示例代码

  5. --installpath=/data/home/sczc338/run/soft/cuda12.5 - 指定CUDA的安装路径

就按照装好了

下面cd到cuda12.5目录下

vi env.sh是在编辑环境脚本

编辑的内容如下:

复制代码
#!/bin/bash
export CUDA_HOME=/data/home/sczc338/run/soft/cuda12.5
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=$CUDA_HOME/lib:$LIBRARY_PATH
export INCLUDE=$CUDA_HOME/include:$INCLUDE
export CPATH=$CUDA_HOME/include:$CPATH

(按i进入编辑模式,编辑好之后首先按Esc退出键,然后输入 :wq 即可退出)(注意要是英语符号)

使用命令

复制代码
 source /data/home/sczc338/run/soft/cuda12.5/env.sh

即可激活环境(cuda12.5)

如何创建 .whl 文件

如果你开发了一个 Python 包,并希望将其打包为 .whl 文件,可以按照以下步骤进行::

确保已安装 setuptoolswheel

复制代码
pip install setuptools wheel

在包含 setup.py 的项目目录中,运行以下命令:​

复制代码
python setup.py bdist_wheel

执行上述命令后,dist 目录中将生成对应的 .whl 文件。

相关推荐
一眼青苔9 小时前
局域网内,将linux(Ubuntu)的硬盘映射成Windows上,像本地磁盘一样使用
linux·windows·ubuntu
zhishishe9 小时前
Word技巧:如何在 Mac 和 Windows 上检索未保存的 Word 文档
windows·macos·word
魔道不误砍柴功13 小时前
《理解 Java 泛型中的通配符:extends 与 super 的使用场景》
java·windows·python
郁大锤17 小时前
Windows 下 Git 入门指南:从安装、配置 SSH 到加速 GitHub 下载
windows·git·ssh
一眼青苔18 小时前
网易云音乐如何修改缓存地址到D盘
windows
青铜弟弟18 小时前
在Windows创建虚拟环境如何在pycharm中配置使用
ide·windows·pycharm
无敌 喵星人21 小时前
ubuntu的各种工具配置
linux·运维·windows
Anarkh_Lee1 天前
Neo4j社区版在win下安装教程(非docker环境)
运维·数据库·windows
Bruce_Liuxiaowei1 天前
[特殊字符]fsutil命令用法详解
windows·cmd