AI

felix.shao2025-08-02

AI

概述

AI 学习路线如下
  • 环境
    • GPU
      • driver 驱动,安装 cuda 时自动安装的
      • CUDA 版本 12.8
    • MODEL
      • vLLM(基础包,兼容性差)
      • conda
        • pytorch(NLP)
        • transformer
        • SGLang
        • openai api
      • ollama
      • xinference
    • AGENT
      • dify
      • coze
      • hiagent
      • RAG
      • mcp
    • Senario
      • prompt-engineering
  • 其他
    • cursor
    • trae
    • claude code

环境安装

安装说明

 Cuda、C++ 版、llm 基础包兼容性差,一定要注意版本。

软件名组件名版本下载链接备注
Windows11
Visual Studio Community2022官网open in new window下载官网默认下载最新版本
cuda12.8
VSCode最新版即可
安装 Visual Studio Community

 官网下载默认最新安装程序安装,安装版本目前是 2022。注意安装下可选插件。

  • 使用 C++ 的桌面开发,大的组件,可能包含后续 3 个组件。
  • Windows 11 SDK。
  • C++ MFC for latest v143 build tools。
  • C++/CLI support。

 安装好后,开始菜单可以找到以下两个程序入口。

  • Visual Studio 2022:主 IDE。
  • Visual Studio Installer:安装可选插件。

 配置环境变量,VSCode 使用 nvcc 需要 cl.exe。

  • Path 新增 D:\devProgram\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64。
Cuda 安装

 先下载,下载链接如下,选择 Windows -> 11 -> exe(local)。下载完成后双击按步骤安装即可。

 安装好后,输入 nvcc -V 验证。
 查询显卡信息命令如下。

  • nvidia-smi: 查询显卡详细信息。
  • nvidia-smi -q:查询 GPU 详细信息。
  • nvidia-smi -q -i 0:查询特定 GPU 详细信息,0 是第几个 GPU。
  • nvidia-smi -q -i 0 -d MEMORY:查询 GPU 特定信息。
Miniconda 安装
  1. 从官网或清华源等加速源 anaconda 官网open in new window 下载好 miniconda 的安装包。
  2. 双击安装包,按步骤安装 conda。
  3. 配置环境变量。D:\devProgram\miniconda3\condabin,配置好后输入 conda -V 验证即可。
  4. 换加速源源,编辑 %USERPROFILE%\.condarc
channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  1. 执行以下命令,管理 conda 环境,并创建一个环境。
# 查看 conda 配置信息
conda info 
# 如上可以看到 env 的目录,可以执行以下命令修改
conda config --add envs_dirs D:\devProgram\miniconda3\envs
# 列出所有的环境
conda env list
# 默认提供了 base 环境,进入某个虚拟环境
conda activate base
# 退出虚拟环境
conda deactivate 
# 创建一个虚拟环境
conda create -n py311 python=3.11
# 查看虚拟环境版本
python-V
conda 安装 pycharm cpu 版本
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu

示例

Cuda Hello 示例执行

 代码如下。

#include <stdio.h>

__global__ void hello_from_gpu()
{
    printf("Hello World from the the GPU\n");
}


int main(void)
{
    hello_from_gpu<<<4, 4>>>();
    cudaDeviceSynchronize();

    return 0;
}

 输入以下命令编译执行。

# 编译
nvcc .\test.cu -o test
# 执行
./test

附录一、参考文献

Last Updated 8/10/2025, 11:48:01 AM