gpt4 book ai didi

julia - 如何让 Julia CuArrays 使用下载的 CUDA 10.2 而不是下载新副本?

转载 作者:行者123 更新时间:2023-12-04 04:13:10 25 4
gpt4 key购买 nike

我有一台互联网连接缓慢且断断续续的机器,因此下载 2.4 Gb 的 CUDA 几乎要花很长时间。我想通过以下代码使用 GPU 编程:

N = 2^2
using CuArrays
x_d = CuArrays.fill(1.0f0, N) # a vector stored on the GPU filled with 1.0 (Float32)
y_d = CuArrays.fill(2.0f0, N) # a vector stored on the GPU filled with 2.0
y_d .+= x_d

问题是每当我运行最后一行代码时,它都会下载一个新的 CUDA 副本:

julia> y_d .+= x_d
Downloading artifact: CUDA10.2

我已经安装了最新的 CUDA。事实上,中断 julia 的下载并再次运行代码就可以了:

julia> y_d .+= x_d
ERROR: InterruptException:
Stacktrace:
[1] compile(::Symbol, ::CUDAnative.CompilerJob; libraries::Bool, dynamic_parallelism::Bool, optimize::Bool, strip::Bool, strict::Bool) at C:\Users\User\.julia\packages\CUDAnative\ierw8\src\compiler\driver.jl:45
[2] #compile#171 at C:\Users\User\.julia\packages\CUDAnative\ierw8\src\compiler\driver.jl:33 [inlined]
[3] cufunction_slow(::Function, ::Type{T} where T, ::Int64; name::String, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\User\.julia\packages\CUDAnative\ierw8\src\execution.jl:326
[4] #219 at C:\Users\User\.julia\packages\CUDAnative\ierw8\src\execution.jl:393 [inlined]
[5] get!(::CUDAnative.var"#219#220"{String,Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},GPUArrays.var"#26#27",DataType,Int64}, ::Dict{UInt64,CUDAnative.HostKernel}, ::UInt64) at .\dict.jl:452
[6] macro expansion at C:\Users\User\.julia\packages\CUDAnative\ierw8\src\execution.jl:392 [inlined]
[7] macro expansion at .\lock.jl:183 [inlined]
[8] cufunction_fast(::Function, ::Type{T} where T, ::Int64; name::String, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\User\.julia\packages\CUDAnative\ierw8\src\execution.jl:391
[9] getproperty at .\Base.jl:33 [inlined]
[10] merge at .\namedtuple.jl:235 [inlined]
[11] cufunction(::GPUArrays.var"#26#27", ::Type{Tuple{CuArrays.CuKernelContext,CUDAnative.CuDeviceArray{Float32,1,CUDAnative.AS.Global},Base.Broadcast.Broadcasted{Nothing,Tuple{Base.OneTo{Int64}},typeof(+),Tuple{Base.Broadcast.Extruded{CUDAnative.CuDeviceArray{Float32,1,CUDAnative.AS.Global},Tuple{Bool},Tuple{Int64}},Base.Broadcast.Extruded{CUDAnative.CuDeviceArray{Float32,1,CUDAnative.AS.Global},Tuple{Bool},Tuple{Int64}}}}}}; kwargs::Base.Iterators.Pairs{Symbol,String,Tuple{Symbol},NamedTuple{(:name,),Tuple{String}}}) at C:\Users\User\.julia\packages\CUDAnative\ierw8\src\execution.jl:0
[12] macro expansion at C:\Users\User\.julia\packages\CUDAnative\ierw8\src\execution.jl:157 [inlined]
[13] gpu_call(::CuArrays.CuArrayBackend, ::Function, ::Tuple{CuArray{Float32,1,Nothing},Base.Broadcast.Broadcasted{Nothing,Tuple{Base.OneTo{Int64}},typeof(+),Tuple{Base.Broadcast.Extruded{CuArray{Float32,1,Nothing},Tuple{Bool},Tuple{Int64}},Base.Broadcast.Extruded{CuArray{Float32,1,Nothing},Tuple{Bool},Tuple{Int64}}}}}, ::Int64; name::String) at C:\Users\User\.julia\packages\CuArrays\e8PLr\src\gpuarrays.jl:32
[14] #gpu_call#1 at C:\Users\User\.julia\packages\GPUArrays\QDGmr\src\device\execution.jl:60 [inlined]
[15] copyto! at C:\Users\User\.julia\packages\GPUArrays\QDGmr\src\host\broadcast.jl:63 [inlined]
[16] copyto! at .\broadcast.jl:864 [inlined]
[17] materialize!(::CuArray{Float32,1,Nothing}, ::Base.Broadcast.Broadcasted{CuArrays.CuArrayStyle{1},Nothing,typeof(+),Tuple{CuArray{Float32,1,Nothing},CuArray{Float32,1,Nothing}}}) at .\broadcast.jl:823
[18] top-level scope at REPL[5]:1

julia> y_d .+= x_d
4-element CuArray{Float32,1,Nothing}:
3.0
3.0
3.0
3.0

但是,每次我运行 CUDA 相关代码时,Julia 都会尝试再次下载。我有一个从 NVIDIA 网站新下载的可执行文件(“cuda_10.2.89_441.22_win10.exe”)。无论如何让 Julia 使用这个副本,或者根本不这样做?

最佳答案

不能 100% 确定(当然,这是一个临时解决方案),但一种解决方案可能是检查 Julia 是否正确加载了动态链接。为了检查它:

using Libdl
DL_LOAD_PATH #(same as Libdl.DL_LOAD_PATH)

之后您应该能够看到 CUDA 库路径列表。如果没有,那么您应该添加它们。

为此,只需键入:

push!(DL_LOAD_PATH, "/path/to/cuda/")

然后尝试导入 CuArrays 包。

顺便说一句,CuArrays 依赖于 CUDAnative 和 CUDAdrv。所以另一种解决方案可能是分别安装所有 3 个包。

关于julia - 如何让 Julia CuArrays 使用下载的 CUDA 10.2 而不是下载新副本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61333232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com