Dear Altruists,
I want to run my PyTorch model in ios GPU and therefore following this post: https://pytorch.org/tutorials/prototype/ios_gpu_workflow.html 14. I have pulled branch v1.8.0 from pytorch git repo and built with the following command:
USE_PYTORCH_METAL=ON python setup.py install --cmake
Though the build was successful, I could not access CUDA devices from the torch (torch.cuda.is_available() returns False). Afterward, I exported my traced model with metal backend after loading in CPU with few warnings.
I built a custom LibTorch from source for ios inference with the following command:
IOS_ARCH=arm64 USE_PYTORCH_METAL=1 ./scripts/build_ios.sh
Now, while I’m trying to run inference in ios device, I’m getting the following error:
Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_MPSCNNSubtract", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNAdd", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSImageTranspose", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSImageDescriptor", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSImage+Tensor.mm.o)
  "_OBJC_CLASS_$_MPSCNNMultiply", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNLogSoftMax", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNNeuronHardSigmoid", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNPoolingAverage", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNPoolingMax", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNNeuronTanH", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNNeuronOp.mm.o)
  "_OBJC_CLASS_$_MPSCNNUpsamplingNearest", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNNeuronSigmoid", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNNeuronOp.mm.o)
  "_OBJC_CLASS_$_MPSCNNConvolutionDescriptor", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNConvOp.mm.o)
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSImage", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
      objc-class-ref in libtorch_cpu.a(MPSImage+Tensor.mm.o)
      l_OBJC_$_CATEGORY_MPSImage_$_Tensor in libtorch_cpu.a(MPSImage+Tensor.mm.o)
      l_OBJC_$_CATEGORY_MPSImage_$_Shaders in libtorch_cpu.a(MPSImage+Tensor.mm.o)
      objc-class-ref in libtorch_cpu.a(MPSImageWrapper.mm.o)
  "_OBJC_CLASS_$_MPSCNNConvolution", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNConvOp.mm.o)
  "_OBJC_CLASS_$_MPSCNNFullyConnected", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNOps.mm.o)
  "_OBJC_CLASS_$_MPSCNNNeuronReLU", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNNeuronOp.mm.o)
  "_OBJC_CLASS_$_MPSCNNDepthWiseConvolutionDescriptor", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSCNNConvOp.mm.o)
  "_OBJC_CLASS_$_MPSTemporaryImage", referenced from:
      objc-class-ref in libtorch_cpu.a(MPSImage+Tensor.mm.o)
  "_MPSSupportsMTLDevice", referenced from:
      -[MPSCNNContext available] in libtorch_cpu.a(MPSCNNContext.mm.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Is it occurring due to the initial CUDA issue?
Is it mandatory to load the model in GPU for metal build?
Or, anything else?