小编Pet*_*man的帖子

如何在 Haskell 上 FFI CUDA 应用程序?

我已将 Haskell 应用程序移植到 CUDA 以加速它。现在,我有一个.cu文件想要从 Haskell 作为 API 调用。我已经通过遵循教程轻松地管理了 FFI C 文件,但我不确定这如何应用于 CUDA/nvcc。如何通过 FFI 访问 CUDA 源文件中定义的符号?

为了完成,这就是我尝试将其视为.cu普通.c文件的内容:

vh:CUDA apple1$ nvcc hello.cu -c -o hello.o
vh:CUDA apple1$ ghc test.hs -o test hello.o
Linking test ...
Undefined symbols for architecture x86_64:
  "___cudaRegisterFatBinary", referenced from:
      __sti____cudaRegisterAll_40_tmpxft_00002168_00000000_7_hello_cpp1_ii_f33df8d2() in hello.o
  "___cudaRegisterFunction", referenced from:
      __nv_cudaEntityRegisterCallback(void**) in hello.o
  "___cudaUnregisterFatBinary", referenced from:
      __cudaUnregisterBinaryUtil() in hello.o
  "_cudaConfigureCall", referenced from:
      render(Renderer_*) in hello.o
  "_cudaFree", referenced from:
      renderer_free(Renderer_*) in hello.o
  "_cudaLaunch", referenced from:
      cudaError …
Run Code Online (Sandbox Code Playgroud)

linker haskell cuda ffi ghc

6
推荐指数
1
解决办法
299
查看次数

PyTorch 中带有偏置的嵌入层和线性层之间有什么区别

我正在阅读“使用 fastai 和 PyTorch 为编码人员进行深度学习”一书。对于 Embedding 模块的作用,我仍然有些困惑。它似乎是一个简短而简单的网络,但我似乎无法理解 Embedding 与没有偏见的 Linear 的不同之处。我知道它做了一些更快的点积计算版本,其中一个矩阵是一个单热编码矩阵,另一个是嵌入矩阵。这样做实际上是为了选择一条数据?请指出我错在哪里。这是书中展示的简单网络之一。

class DotProduct(Module):
    def __init__(self, n_users, n_movies, n_factors):
        self.user_factors = Embedding(n_users, n_factors)
        self.movie_factors = Embedding(n_movies, n_factors)
        
    def forward(self, x):
        users = self.user_factors(x[:,0])
        movies = self.movie_factors(x[:,1])
        return (users * movies).sum(dim=1)
Run Code Online (Sandbox Code Playgroud)

python oop deep-learning pytorch fast-ai

3
推荐指数
1
解决办法
777
查看次数

标签 统计

cuda ×1

deep-learning ×1

fast-ai ×1

ffi ×1

ghc ×1

haskell ×1

linker ×1

oop ×1

python ×1

pytorch ×1