Category: Integration with Other Languages and Systems

Packing structs for opencl

struct MyStruct a::Int b::Float64 c::String end function pack_structs(arr::Array{MyStruct,1}) packed_arr = Array{UInt8}(undef, sizeof(MyStruct)*length(arr)) for i in 1:length(arr) offset = sizeof(MyStruct)*(i-1) packed_arr[offset+1:offset+sizeof(MyStruct)] = reinterpret(UInt8, pointer(arr[i])) end return packed_arr end Solution 1: Using reinterpret One

Read More »

Cant get cuda jl to see cuda in ubuntu

using CUDAdrv using CuArrays function check_cuda() if CUDAdrv.has_cuda() println(“CUDA is available”) else println(“CUDA is not available”) end end check_cuda() Solution 1: Installing CUDA Toolkit The first solution to the problem of not

Read More »

Error with torch jl

using Pkg Pkg.add(“Torch”) Option 1: Installing Torch If you are encountering an error with the Torch package in Julia, the first solution is to install the package using the Pkg module. The

Read More »