mxnet1.9.1+cuda11.8+rtx4090+vs2022+win11源码编译安装

win11动手学深度学习安装过程(GPU版)( CUDA Anaconda Mxnet ) win11,动手学深度学习安装过程(GPU版)( CUDA / Anaconda / Mxnet )(备忘) 一、检查及安装CUDA 首先检查显卡支持的cuda: 直接搜索NVIDIA,选择NVIDIA控制中心, 可以看到NVIDIA支持的最高CUDA 然后是安装 https://developer.nvidia.com/cuda-toolkit-archive 选择需要的版本,我这里选择的是v10.1 注: 我的显卡是GeForce RTX3060,查找后支持的Cuda最高版本是cuda1 阅读详情
AI摘要

本文详细介绍了如何在Windows 11环境下,使用Visual Studio 2022、CUDA 11.8、RTX 4090显卡,从源码编译安装MXNet 1.9.1的过程,包括CUDA、CUDNN、OpenBLAS和OpenCV的配置,以及解决编译和安装中的问题。

官方文档:https://mxnet.apache.org/versions/1.9.1/get_started/windows_setup#build-from-source

1.简介

最近在学习 mxnet,虽然它过气了,但是还是一个很好的学习平台,毕竟教程搞得好,大家都来搞。
既然搞了深度学习那必须用gpu啦,但是mxnet的预编译包最多只支持 cuda11.7,而且好像还不支持windows平台
看这张图片,前面说了支持 Linux 和 Windows 平台,后面又说 Windows 是其他平台,需要从源码构建
pC6gQhT.png

还可以查找下这个链接:https://dist.mxnet.io/python,反正我是没找到1.9.1且适配cuda117的windows的.whl文件

官方文档呢,给出的是 vs2017 + cuda9.2 的编译,cuda9.2 是不能支持 rtx4090 显卡的最大计算能力8.9的
所以还是有坑,而且官方文档你不一定能编译的出来…

而且找遍了全网好像也没有最新的编译流程,只好自己搞一遍了,果然是过气了啊。

2.准备

最基础的cmake和vs2022就不说了

2.1 cuda

首先我们要选择合适的 cuda 版本,官方已经给出了cuda11.7的构建包,虽然是Linux上的,也说明了兼容11.7 ,十有八九不兼容12
所以我们的选择范围就是cuda11.x

nvidia显卡还有一个特性叫计算能力,或者叫做架构,每一代的显卡有不同的架构,在编译时会自动选择当前显卡支持的最新架构
所以需要使用可以兼容当前显卡最新架构的cuda版本,首先查看显卡信息
pC6ho0H.png

由于使用的是4090显卡,需要查看显卡支持的最大计算能力:https://developer.nvidia.com/cuda-gpus
下图可以看到30系显卡支持8.6的计算能力,40系支持到8.9
pC6hzng.png

而cuda本身对计算能力有一个支持列表,实际上,cuda11.7不支持8.9,只有cuda11.8才支持8.6
尽管我们可以编译较低等级的架构,也可以在高等级架构的gpu上运行,但是这可能会产生其他问题
所以最好直接编译当前gpu支持的最高架构的代码
pC646KS.png

最后我们选择了cuda11.8,也就是官方没有提供的最近的一个版本
尽管系统里安装了11.8和12.2两个版本,但是它们是可以互不影响的,只需要设置CUDA_PATH为使用的版本,且将其加入PATH

2.2 cudnn

下载支持cuda11.8的cudnn版本:https://developer.nvidia.com/cudnn

2.3 OpenBLAS

首先下载 OpenBLAS https://github.com/xianyi/OpenBLAS/releases
然后配置OpenBLAS_HOME指向其内部的build目录,下面包含了bin和include目录

2.4 OpenCV

使用Chocolatey安装OpenCV,实际上就是从github下载 https://github.com/opencv/opencv/releases
pC65VPI.png
然后配置OpenCV_DIR指向 opencv/build 目录

2.5 mxnet

下载源码 https://github.com/apache/mxnet ,且到1.9.1分支

3.生成

使用cmake生成编译工具链

cmake -DUSE_CUDA=1 -DUSE_CUDNN=1 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_BLAS=open -DUSE_LAPACK=1 -DUSE_DIST_KVSTORE=0 -DCUDA_ARCH_LIST=Common -DCUDNN_LIBRARY='D:\dev\IDE\nvidia\cudnn-8.9.1.23_cuda11\lib\x64\cudnn.lib' -DCUDNN_INCLUDE='D:\dev\IDE\nvidia\cudnn-8.9.1.23_cuda11\include' .

CUDNN_LIBRARY:指向cudnn.lib文件
CUDNN_INCLUDE:指向cudnn的include目录

生成完毕后可以看到mxnet.sln文件

但是还有一个小问题,每个cuda版本安装时都会在vs的目录下安装一些文件,我们生成的工具链里使用了12.2版本的文件
因为实际上使用的是cuda11.8,所以需要更改这些文件为11.8
pC65hee.png

4.编译

打开 native x64 command line , 运行编译,大概一个半小时

msbuild mxnet.sln /p:Configuration=Release;Platform=x64 /maxcpucount

pC65xoj.png

编译完成后会在Release目录下生成 mxnet.dll 和 mxnet_89.dll

5.安装

安装的一个前置工作是,必须保证所有的dll在PATH中可用:

  • cudart64_110.dll:来自cuda
  • libopenblas.dll:来自openblas
  • libgcc_s_seh-1.dll:来自mingw64
  • libgfortran-5.dll:来自mingw64
  • libquadmath-0.dll:来自mingw64
  • libwinpthread-1.dll:来自mingw64
  • opencv_world470.dll:来自opencv
  • cudnn64_8.dll:来自cudnn

配置MXNET_LIBRARY_PATH 环境变量指向 libmxnet.dll
然后执行安装 pip install ./python

6.测试

import mxnet as mx
print(1)
a = mx.nd.ones((2, 3), mx.gpu(0))
print(a)
b = a * 2 + 1
print(b)
print(b.asnumpy())

得到在gpu 上分配的结果

1

[[1. 1. 1.]
 [1. 1. 1.]]
<NDArray 2x3 @gpu(0)>

[[3. 3. 3.]
 [3. 3. 3.]]
<NDArray 2x3 @gpu(0)>
[[3. 3. 3.]
 [3. 3. 3.]]

到此为止,使用cuda11.8 编译的兼容8.9架构的mxnet就可以使用了

Win11 RTX 4090显卡深度学习环境配置(Nvidia显卡驱动、CUDA11.7.0) Win11 RTX4090显卡深度学习环境配置,安装pytorch、CUDA。 阅读详情

相关推荐

MXNET 1.9.1源码

mxnet 1.9.1源码,可以在rk3588上成功编译

国产PLC实战:用汇川Easy320搞定TCP通信,手把手教你网口转串口控制设备

本文详细解析了如何使用汇川Easy320 PLC实现TCP通信与串口控制,解决工业自动化中设备间通信协议差异问题。通过实战案例和代码示例,展示了Easy320在协议转换、数据解析和串口转发中的高效应用,帮助工程师快速掌握网口转串口控制技术。

weixin_31774841的博客 504

《机器学习》周志华_自学记录

第一章绪论## 1.1引言机器学习所研究的主要内容,是关于在计算机上从数据中产生"模型"(model)的算法,即"学习算法"(learning algorithm).在面对新的情况时(例如看到一个没剖开的西瓜),模型会给我们提供相应的判断(例如好瓜).如果说计算机科学是研究关于"算法"的学问,那么类似的,可以说机器学习是研究关于"学习算法"的学问.## 1.2基本术语:用于预测离散值,例如将样本分为“好瓜”或“坏瓜”。:用于预测连续值,例如西瓜的成熟度(如0.95、0.37)。

2201_75296678的博客 2535

Android安全支付(1)-整体架构-keymint

(1)接口定义hardware/interfaces/security/keymint/aidl/android/hardware/security/keymint/IKeyMintDevice.aidl。keymint是keymaster v4之后的替代设计。所以android 15上最好采用keymint的接口进行硬件功能的对接。同时,我们会集成一款紫光的芯片。3.可以用keyStore.getKey()来获取存储在keyStore中的数据进行加密和解密。四、关于keymint的接口定义和具体实现。

Android系统开发-VR OS-系统安全隐私 1771

Fortify SCA 24.4 最新可用版

Fortify Static Code Analyzer(Fortify SCA) 是一款由 Micro Focus(原惠普旗下)开发的 静态应用安全测试(SAST)工具,专注于在软件开发早期通过分析源代码或编译后的二进制文件,识别潜在的安全漏洞、代码缺陷和合规性问题。以下是其核心特点与功能:核心功能 静态代码分析 在不运行程序的情况下,通过语法、语义分析检测代码中的安全漏洞(如 SQL 注入、跨站脚本(XSS)、缓冲区溢出等)和代码质量问题。

棉花糖的博客 3186

petalinux i2c的配置

1.硬件平台配置 1.内核配置 cd petalinux-config -c kernel -> Device Drivers -> I2C support -> i2C Hardware Bus support -> Xilinx I2C Controller Pressing 启用CONFIG_I2C_XILINX=y 2.修改用户设备树 cd cd project-spec/meta-user/recipes-bsp/device-tree/files/ i2c2:

u013403954的博客 4315

LLaMA-Factory微调教程5:多模态VLM模型对话

视觉-语言模型(VLM)概述与应用 视觉-语言模型(VLM)是一类结合视觉和语言信息的人工智能模型,旨在实现跨模态的理解与交互。其核心目标包括跨模态理解和生成能力,关键技术涉及模态表示与映射、多模态预训练以及跨模态交互机制。 典型VLM模型包括: CLIP:通过对比学习实现图像和文本的向量空间对齐 BLIP:结合自监督和弱监督学习提升语义对齐 ALBEF:基于BERT结构扩展跨模态注意力 DALL-E系列:基于文本生成图像的生成式模型 CLIP4Clip:扩展CLIP到视频领域 VLM在图像/视频检索、视觉

Cachel Wood的博客 1115

【Unity优化篇】| Unity3D场景 常用优化策略,遮挡剔除、层消隐距离技术 和 LOD多层次细节

本篇文章来简单介绍一下 Unity中几种常用3D场景优化策略 方法 对于整个项目来说,本文中出现的方法也只是冰山一角,慢慢积累学习吧! 内容包括遮挡剔除(Occlusion Culling)、层消隐距离技术 和 LOD多层次细节

努力前行,总会成为自己心中的那道光 1万+

解决TexStudio编写LaTeX论文引用文献问题:正文引用处出现[?],参考文献也不显现

当我们利用LaTeX编写论文时,可能会出现引用参考文献时正文引用处出现?号,肯能的原因及解决方案如下: 问题一 忘记在\end{document}前面放\bibliographystyle{样式}和\bibliography{参考文献bib文件名}: \bibliographystyle{plain} \bibliography{sample} 其中, LaTeX 标准选项及其样式共有以下8种: plain,按字母的顺序排列,比较次序为作者、年度和标题. unsrt,样式同plain,只是按照引用的先后

左手の明天的博客 9533

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

上一篇: nodejs源码解析之一 (windows 编译脚本 vcbuild.bat)
下一篇: 基于Redis 的任务队列Bull -- (一)简介
afan_coding
博客等级 码龄4年 7粉丝 22原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

afan_coding

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值