Comments (3)
Your kernel is constructing a Normal{Float32}(0.f0, 1.f0)
object for every state
index. On top of being very inefficient, this code will not run on GPU as it creates allocations.
What if you tried:
function kernel(state, dist)
idx = thread_position_in_grid_1d()
state[idx] = rand(dist)
return
end
n = 10
state = Metal.ones(n)
@metal threads=n kernel(state, Normal{Float32}(0f0,1f0))
from metal.jl.
In the actual code, the distribution depends on the state, something like Normal(state[idx], 1.f0)
. Tried running your example but that still raises a pgstack error.
julia> @metal threads=n kernel(state, Normal{Float32}(0f0,1f0))
ERROR: InvalidIRError: compiling MethodInstance for kernel(::MtlDeviceVector{Float32, 1}, ::Normal{Float32}) resulted in invalid LLVM IR
Reason: unsupported call to an unknown function (call to julia.get_pgcstack)
Stacktrace:
[1] randn_unlikely
@ ~/.julia/juliaup/julia-1.9.4+0.aarch64.apple.darwin14/share/julia/stdlib/v1.9/Random/src/normal.jl:81
[2] multiple call sites
@ unknown:0
These are the system info:
macOS 14.5.0, Darwin 23.5.0
Toolchain:
- Julia: 1.10.4
- LLVM: 15.0.7
Julia packages:
- Metal.jl: 1.2.0
- LLVMDowngrader_jll: 0.3.0+1
1 device:
- Apple M1 Max (384.000 KiB allocated)
from metal.jl.
External packages not supporting GPU execution is not a bug in the GPU support package, so it's probably better to file an issue on Distributions.jl for GPU compatibility. If that reveals specific features are needed for that support, you can file them here.
For example, your stack trace seems to show that rand
is called by Distributions, which is currently not supported by Metal.jl kernels. If you can confirm that and create a MWE of what's needed, feel free to open a new issue with that information (but know that RNG support in kernels is fairly involved, see e.g. the CUDA.jl implementation, https://github.com/JuliaGPU/CUDA.jl/blob/master/src/device/random.jl).
(For other questions like this, something in GitHub's discussions, or on Discourse or Slack, is probably better suited than filing a bug report.)
from metal.jl.
Related Issues (20)
- M1/M2: Large matrix multiplications can contains NaNs HOT 29
- `MTLBinaryArchive`
- `Metal.code_agx()` failing in MacOS 15 Beta 3 HOT 2
- Test for min / max broadcasting issue HOT 5
- Add a `metal_version` function
- Type piracy HOT 1
- Potentially unused code in gpuarrays.jl
- Control flow-related miscompilation: HOT 1
- Implement MPSMatrixSolve HOT 1
- `Shared` vs `SharedStorage` in examples/unified_memory HOT 2
- More sporadic 1.11 hangs HOT 4
- EnzymeRules for MTLArray Constructor
- Support for `LinearAlgebra.kron` HOT 2
- Can't use gemm! methods with Metal HOT 3
- Error for thread/group size with different integer types HOT 6
- README example broken HOT 2
- Intermittent load_store_tg test failure HOT 3
- Display summary for `Metal.@profile`
- Simple throwing kernel hangs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from metal.jl.