当前位置: 首页 > news >正文

简单的网站源码新东方烹饪学校学费价目表

简单的网站源码,新东方烹饪学校学费价目表,免费软件大全app下载,旅游网站设计说明书上一篇文章#xff1a;【2025深度学习环境搭建-1】在Win11上用WSL2和Docker解锁GPU加速 先启动Docker#xff01;对文件内容有疑问#xff0c;就去问AI 一、用Docker拉取pytorch镜像#xff0c;启动容器#xff0c;测试GPU docker pull pytorch/pytorch:2.5.0-cuda12.4…上一篇文章【2025深度学习环境搭建-1】在Win11上用WSL2和Docker解锁GPU加速 先启动Docker对文件内容有疑问就去问AI 一、用Docker拉取pytorch镜像启动容器测试GPU docker pull pytorch/pytorch:2.5.0-cuda12.4-cudnn9-devel docker run -it --rm --gpus all pytorch/pytorch:2.5.0-cuda12.4-cudnn9-devel nvidia-smi 别忘了用--gpus all启用GPU 能出现显卡信息说明基于该镜像的容器是可以用gpu的。之后要把这个镜像应用到到我们的开发环境之中使用VS Code插件Dev Container 二、安装VS Code插件 三、创建项目文件测试pytorch和GPU的python程序 创建文件夹pytorch-test并在其目录下创建如下文件夹和文件(主要创建app.py和.devcontainer就行其他的随意) 需要创建的文件内容如下 requirements.txt 这个文件内容为空 app.py import torch a[1,23,4,5,.4] def print_gpu_info():# 检查CUDA是否可用cuda_available torch.cuda.is_available()print(fCUDA 是否可用: {cuda_available})if not cuda_available:return# 获取GPU数量device_count torch.cuda.device_count()print(f\n可用的GPU数量: {device_count})# 打印每个GPU的详细信息for i in range(device_count):print(f\n GPU {i} )print(f名称: {torch.cuda.get_device_name(i)})prop torch.cuda.get_device_properties(i)print(f总内存: {prop.total_memory / 1024**3:.2f} GB)print(f多处理器数量: {prop.multi_processor_count})print(f计算能力: {prop.major}.{prop.minor})def test_gpu_operation():# 尝试在GPU上执行操作if torch.cuda.is_available():try:# 创建测试张量x torch.randn(3, 3).cuda()y torch.randn(3, 3).cuda()z x y # 执行GPU计算# 验证设备类型print(\n GPU 操作测试 )print(f张量所在设备: {x.device})print(GPU 计算成功)return Trueexcept Exception as e:print(f\nGPU 操作失败: {str(e)})return Falseelse:print(没有可用的GPU进行测试)return Falseif __name__ __main__:print( PyTorch GPU 信息 )print_gpu_info()print(\n GPU 功能测试 )test_result test_gpu_operation()print(\n 最终状态 )print(fGPU 是否可用: {torch.cuda.is_available()})print(fGPU 是否可用: {test_result})print(fPyTorch 版本: {torch.__version__}).devcontainer/devcontainer.json // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile {name: GPU Development,torch2.5cu124cudnn9,Py3.11.10,runArgs: [--gpusall // 添加 GPU 支持],build: {// Sets the run context to one level up instead of the .devcontainer folder.context: ..,// Update the dockerFile property if you arent using the standard Dockerfile filename.dockerfile: Dockerfile},customizations: {vscode: {extensions: [ms-python.python,ms-toolsai.jupyter,ms-python.autopep8,ms-python.vscode-pylance,mechatroner.rainbow-csv,ms-azuretools.vscode-docker,ms-toolsai.datawrangler]}}// Features to add to the dev container. More info: https://containers.dev/features.// features: {},// Use forwardPorts to make a list of ports inside the container available locally.// forwardPorts: [],// Uncomment the next line to run commands after the container is created.// postCreateCommand: cat /etc/os-release,// Configure tool-specific properties.// customizations: {},// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.// remoteUser: devcontainer } .devcontainer/Dockerfile # 使用 PyTorch 官方镜像作为基础镜像 FROM pytorch/pytorch:2.5.0-cuda12.4-cudnn9-devel# 设置工作目录容器中的 WORKDIR /workspace# 将本地代码复制到容器中 COPY . /workspace# 安装额外的依赖如果有 RUN pip install --no-cache-dir -r requirements.txt# 暴露端口如果有需要 # EXPOSE 8000# 定义容器启动时运行的命令 # CMD [python, app.py]README.md ## pip环境导入导出 从requirements.txt导入环境 pip install --no-cache-dir -r requirements.txt 导出环境到文件requirements.txt pip freeze | grep -v file:// requirements.txt四、打开项目文件并使用容器环境 在VS Code中打开项目文件 按下【F1】在上方选择【Dev Containers:Reopen in Container】 此时查看vscode左下角蓝底白字显示Dev Container: GPU Development,torch2.5..就说明我们现在的项目torch-test已经在使用刚才拉取的pytorch容器了 在左边找到app.py运行他若显示可用gpu大于0表示项目torch-test中的python程序可以使用gpu。之后我们需要运行深度学习程序时使用这里的步骤即可不需要安装额外的python环境了若需要安装其他包那就修改requirements.txt文件即可。 五、需要安装其他python包怎么办 若我们需要其他python包那就在终端直接安装测试能用之后用pip freeze | grep -v file:// requirements.txt将当前python环境中的包导出到文件requirements.txt中。 之后再启动项目时Dev Container会自动帮我们根据文件requirements.txt安装环境。 清空文件requirements.txt中的内容之后重新构建容器即可得到一个原始镜像中的python环境 补充如何重新构建容器 按【F1】搜索【Dev Containers:Rebuild Container】 补充在镜像中添加VS Code插件 可以在镜像中添加VS Code插件之后每次构建镜像都会自动安装插件不用自己手动安装了 方法右键单击插件点击【Add to devcontainer.json】 参考 教程使用 Visual Studio Code 创建 Docker 应用 借助 Visual Studio Code 将 Docker 容器用作开发环境
http://www.hkea.cn/news/14525181/

相关文章:

  • 为什么要建设门户网站长兴县建设局网站
  • 网络维护网站美工惠州网站建设哪家强
  • 加盟网网站建设标签下载wordpress
  • php做的静态网站怎么加密个人智慧团建系统登录
  • 有口碑的番禺网站建设ui设计职业培训机构
  • 建网站解决方案seo网站推广价格
  • 专门做网站的公司与外包公司有哪些新乡市工程建设信息网
  • 自己怎么做网站优化西安手机网站建设公司排名
  • 佛山建网站哪家好网站网站开发逻辑
  • cms建站仓储网站开发
  • 成都营销型网站建设公司广州新闻报道
  • 做 个收废品网站做百度推广怎么做才能有电话
  • 有哪些网站做的很好wordpress压缩数据库查询
  • 网站建设需要材料关于旅游案例的网站
  • 建设部网站投诉如何注册遵义住房和城乡建设局网站
  • 如何在学校网站上做链接免费公司介绍网站怎么做
  • 经典网站赏析信息化工作总结 网站建设
  • 嵊州建设银行取款网站大兴建设网站公司
  • 佛山做推广网站的怎样推广才能让更多人看到
  • 网站未收录wordpress图片文件夹更换
  • 网站制作学习上海互联网网站建设
  • 刚做的网站怎么在百度搜到wordpress询盘插件
  • 温州做外贸网站网站 服务器选择
  • 电商网站免费设计wordpress主题 反盗版
  • 哪里制作企业网站那种直播软件从哪里下载
  • 游戏ui素材网站大数据营销模式
  • 商城网站建设 优帮云一级a做爰片免费网站国语
  • 宁波网站推广服务wordpress特定主题
  • 惠州城乡住房建设厅网站南县网站制作
  • 部署推进网站建设网站策划书撰写流程