切换版块
×
基础软件平台
PyTorch开发
TensorFlow开发
编解码及SDK开发
BANG语言与计算库
开发工具链
MagicMind开发
软件栈百科
云平台集成
硬件产品专区
MLU370系列AI加速卡
MLU270系列AI加速卡
MLU220系列AI加速产品
经验方案交流区
经验案例与实践分享
开发者服务
开发者活动
公告与版务
高校支持
《智能计算系统》
签到
版块
社区
文档
SDK下载
370系列
200系列
开发平台
官网首页
注册
登录
全部版块
基础软件平台
硬件产品专区
经验方案交流区
开发者服务
高校支持
发布新帖
登录/注册
LV.1
Zhang123
69
积分
4
赞
12
帖子
28
回复
0
收藏
TA的动态
TA的帖子
TA的回复
pytorch准备工作
我的回复:#1zhangyanting回复您好,您下载的是论坛“SDK下载”中的cambricon_pytorch镜像吗?该镜像的/torch/目录下并没有cambricon_neuware,不会对您跑mlu有额外影响。展开谢谢 谢谢我要是实现算子的开发与测试,用到了cnpluginyu与pytroch不会影响就好
0
Catch中的setup.py不能运行的问题
我的回复:#1zhangyanting回复您好,您的报错来看是头文件链接的问题,能否烦请您指出您编译的具体脚本?因为不是很懂 所以全粘上了 麻烦您了
0
Catch中的setup.py不能运行的问题
我的回复:#1zhangyanting回复您好,您的报错来看是头文件链接的问题,能否烦请您指出您编译的具体脚本?#!/usr/bin/env pythonfrom __future__ import print_functionimport osimport reimport sysimport statimport globimport shutilimport subprocessimport distutils.ccompilerimport distutils.command.cleanfrom setuptools import setup, find_packages, distutilsfrom torch.utils.cpp_extension import BuildExtension, CppExtension################################################################################# Parameters parsed from environment################################################################################RUN_BUILD_CORE_LIBS = TrueRUN_BUILD_OFFLINE_DEMO = bool((os.getenv('BUILD_OFFLINE_DEMO') is None) or (os.getenv('BUILD_OFFLINE_DEMO').upper() not in ['OFF', '0', 'NO', 'FALSE', 'N']))RUN_AUTO_GEN_CATCH_CODE = TrueRUN_BUILD_ASAN_CHECK = FalseRUN_BUILD_WARNING_CHECK = Truefor i, arg in enumerate(sys.argv): if arg == 'clean': RUN_BUILD_CORE_LIBS = False RUN_BUILD_OFFLINE_DEMO = False RUN_AUTO_GEN_CATCH_CODE = False# Get the current path, core library paths and neuware pathcwd = os.path.dirname(os.path.abspath(__file__))lib_path = os.path.join(cwd, "torch_mlu", "csrc", "lib")neuware_path = os.path.join(cwd, "third_party", "neuware")# NEUWARE_HOME env must be set before compilingif not os.getenv('NEUWARE_HOME'): if os.path.exists(os.path.join(neuware_path, "lib64")): os.environ['NEUWARE_HOME'] = neuware_path else: print("[Error] can't find NEUWARE_HOME, Please set it!") print("Or use script/build_mlu_libs.sh to generate Neuware!") sys.exit()# Get Pytorch Dirbase_dir = os.path.dirname(os.path.abspath(__file__))pytorch_source_path = os.getenv('PYTORCH_HOME', os.path.dirname(base_dir))# lib/pythonx.x/site-packagesrel_site_packages = distutils.sysconfig.get_python_lib(prefix='')# full absolute path to the dir abovefull_site_packages = distutils.sysconfig.get_python_lib()# Define the compile and link optionsextra_link_args = []extra_compile_args = []# Check env flagdef _check_env_flag(name, default=''): return os.getenv(name, default).upper() in ['ON', '1', 'YES', 'TRUE', 'Y']# make relative rpathdef make_relative_rpath(path): return '-Wl,-rpath,$ORIGIN/' + path# Generate parts of header/source files in Catch automaticallydef gen_catch_code(pytorch_source_path_): os.system('python torch_mlu/tools/gen.py' + ' --pytorch_dir' + ' ' + pytorch_source_path_)# Calls build_catch_lib.sh with the corrent env variablesdef build_libs(): build_libs_cmd = ['bash', os.path.join('..', 'script', 'build_catch_lib.sh')] my_env = os.environ.copy() my_env["PYTORCH_PYTHON"] = sys.executable my_env['CMAKE_INSTALL'] = 'make install' cmake_prefix_path = full_site_packages if "CMAKE_PREFIX_PATH" in my_env: cmake_prefix_path = my_env["CMAKE_PREFIX_PATH"] + ";" + cmake_prefix_path my_env["CMAKE_PREFIX_PATH"] = cmake_prefix_path my_env["PYTORCH_SOURCE_PATH"] = pytorch_source_path # Keep the same compile and link args between setup.py and build_catch_lib.sh my_env["EXTRA_COMPILE_ARGS"] = ' '.join(extra_compile_args) my_env["EXTRA_LINK_ARGS"] = ' '.join(extra_link_args) # set up the gtest compile runtime environment. my_env['BUILD_TEST'] = 'ON' if _check_env_flag('BUILD_TEST') else 'OFF' try: os.mkdir('build') except OSError: pass kwargs = {'cwd': 'build'} if subprocess.call(build_libs_cmd, env=my_env, **kwargs) != 0: print("Failed to run '{}'".format(' '.join(build_libs_cmd))) sys.exit(1)class Build(BuildExtension): def run(self): # Run the original BuildExtension first. We need this before building # the tests. BuildExtension.run(self)class Clean(distutils.command.clean.clean): def run(self): try: with open('.gitignore', 'r') as f: ignores = f.read() pat = re.compile(r'^#( BEGIN NOT-CLEAN-FILES )?') for wildcard in filter(None, ignores.split('\\n')): match = pat.match(wildcard) if match: if match.group(1): # Marker is found and stop reading .gitignore. break # Ignore lines which begin with '#'. else: for filename in glob.glob(wildcard): try: os.remove(filename) except OSError: shutil.rmtree(filename, ignore_errors=True) except OSError: shutil.rmtree('build', ignore_errors=True) # It's an old-style class in Python 2.7... distutils.command.clean.clean.run(self)# Configuration for Build the Project.main_libraries = ['catch_python']include_dirs = []library_dirs = []# Fetch the sources to be built.torch_mlu_sources = ( glob.glob('torch_mlu/csrc/stub.cpp'))# include head filesinclude_dirs += [ base_dir, pytorch_source_path, os.path.join(pytorch_source_path, 'torch', 'csrc'), os.path.join(pytorch_source_path, 'torch', 'lib', 'tmp_install', 'include'),]#include lib fileslibrary_dirs.append(lib_path)extra_compile_args += [ '-std=c++11', '-pthread', '-Wno-sign-compare', '-Wno-deprecated-declarations', '-Wno-return-type', '-Werror',]DEBUG = _check_env_flag('DEBUG')if RUN_BUILD_ASAN_CHECK: # To get a reasonable performace add -O1 or higher. # run executable with LD_PRELOAD=path/to/asan/runtime/lib extra_compile_args += ['-O1', '-g', '-DDEBUG', '-fsanitize=address', '-fno-omit-frame-pointer']elif DEBUG: extra_compile_args += ['-Og', '-g', '-DDEBUG']else: extra_compile_args += ['-O3']TEST_COVERAGE = _check_env_flag('TEST_COVERAGE')if TEST_COVERAGE: extra_compile_args += ['-fprofile-arcs', '-ftest-coverage'] extra_link_args += ['-fprofile-arcs', '-ftest-coverage'] #to test coverage, these args are necessary# Replace pre-commit of .git to use cpplintif os.path.exists(os.path.join(cwd, '.git')): shutil.copyfile(base_dir + '/script/hooks/commit-msg', base_dir + '/.git/hooks/commit-msg') shutil.copyfile(base_dir + '/script/hooks/pre-commit', base_dir + '/.git/hooks/pre-commit') # Set the file permission to 755 os.chmod(base_dir + '/.git/hooks/pre-commit', stat.S_IRWXU+stat.S_IROTH+stat.S_IXOTH+stat.S_IRGRP+stat.S_IXGRP) os.chmod(base_dir + '/.git/hooks/commit-msg', stat.S_IRWXU+stat.S_IROTH+stat.S_IXOTH+stat.S_IRGRP+stat.S_IXGRP)# Generate parts of Catch codeif RUN_AUTO_GEN_CATCH_CODE: gen_catch_code(pytorch_source_path)# Build Catch Core Libsif RUN_BUILD_CORE_LIBS: build_libs()# the list of runtime dependencies required by this built packageinstall_requires = []# Setupsetup( name='torch_mlu', version='0.15.0-1', description='MLU bridge for PyTorch', # Exclude the build files. packages=find_packages(exclude=['build']), ext_modules=[ CppExtension( '_MLUC', libraries=main_libraries, sources=torch_mlu_sources, include_dirs=include_dirs, extra_compile_args=extra_compile_args, library_dirs=library_dirs, extra_link_args=extra_link_args + [make_relative_rpath('torch_mlu/csrc/lib')]), ], install_requires=install_requires, package_data={ 'torch_mlu': [ 'csrc/lib/*.so*', 'csrc/aten/cnnl/cnnlDescriptors.h', 'csrc/aten/cnnl/cnnlHandle.h', 'csrc/aten/cnnl/cnnlQuantify.h', 'csrc/aten/core/allocator.h', 'csrc/aten/core/caching_allocator.h', 'csrc/aten/core/profiler_mlu.h', 'csrc/aten/core/tensor_impl.h', 'csrc/aten/core/tensor_util.h', 'csrc/aten/device/device.h', 'csrc/aten/device/exceptions.h', 'csrc/aten/device/guard_impl.h', 'csrc/aten/device/mlu_guard.h', 'csrc/aten/device/notifier.h', 'csrc/aten/device/queue_guard.h', 'csrc/aten/device/queue.h', 'csrc/aten/device/types.h', 'csrc/aten/operators/op_proxy.h', 'csrc/aten/util/cnlog.h', 'csrc/aten/util/common.h', 'csrc/aten/util/infer_trans_size.h', 'csrc/aten/util/matrix_util.h', 'csrc/aten/util/memory_allocator.h', 'csrc/aten/util/python_interface.h', 'csrc/aten/util/python_notifier.h', ], }, cmdclass={ 'build_ext': Build, 'clean': Clean, })# do some specified operationsif RUN_BUILD_OFFLINE_DEMO: # Because pycocotools depends on Cython, so Cython must be installed firstly. # However, the installing order of packages in requirements.txt is random, so # Cython and pycocotools can't be installed by requirements.txt os.system('pip install Cython==0.29.16') os.system('pip install pycocotools==2.0.0')# build offline demosif RUN_BUILD_OFFLINE_DEMO: print("==BUILD OFFLINE DEMO==") subprocess.check_call('examples/offline/scripts/build_offline.sh')
0
编译catch部分遇到的问题
我的回复:#4tanhaojue回复您好,可以试一下,在路径:catch/script下执行命令 ./config_for_release.sh 1编译catch和torch。具体可参考《寒武纪PyTorch用户手册》-编译和安装。展开运行 config_for_release.sh是做什么的那
0
寒武纪 pytorch-mlu 添加逐层算子方法除了PyTroch使用手册 还有其他的参考材料吗
我的回复:#1zhangyanting回复您好,关于BANGC算子开发和pytorch添加算子,您还可以参考《寒武纪CNPlugin用户手册 — 寒武纪CNPlugin用户手册 1.12.1 文档 (cambricon.com)》,《寒武纪 BANG C 性能调优指南 — 寒武纪 BANG C性能调优指南 2.15.0 文档 (cambricon.com)》和《寒武纪 BANG C 性能调优指南 — 寒武纪 BANG C性能调优指南 2.15.0 文档 (cambricon.com)》展开这些很容易找到的参考资料 我都看过了 我自己技术不行有些地方看不明白 想找一些其他的 材料
1
cnplugin编译问题
我的回复:#1zhangyanting回复您好,ccache主要用于在编译时加速,建议您按照要求下载,以节省编译时间。谢谢啊 解决了
1
build_cnplugin.sh时报错
我的回复:#1zhangyanting回复您好,您可以先通过find / -name "mlu.h"检查一下您是否有mlu.h,如果没有您可以重新拉取cambricon镜像,或安装CNToolKit包;如果有,检查一下NEUWARE_HOME和LD_LIBRARY_PATH是否正确。展开谢谢你的方案 我在.cc文件中 引用.mluz中entry函数的头文件解决了此问题
0
cnplugin编译问题
我的回复:解决了 cnplugin对算子集成是只需要.cc文件与cnplugin.h中的声明 对于.mlu中的函数需要在 头文件中声明 即类似这样,即可解决#ifndef __HARDSWISH_KERNEL_H__#define __HARDSWISH_KERNEL_H__#ifdef __cplusplusextern "C" {#endifvoid HardSwishKernel_MLU270(void * input, void * output, int input_size, int data_type);#ifdef __cplusplus}#endif#endif // __HARDSWISH_KERNEL_H__
1
cnplugin编译问题
我的回复:#1zhangyanting回复您好,ccache主要用于在编译时加速,建议您按照要求下载,以节省编译时间。嗯嗯已经可以编译了 出现了 其他错误
1
cnplugin部署问题BANG C算子封装成CNPlugin接口。
我的回复:#1zhangyanting回复您好,Cambricon-CNPlugin-MLU270属于未开放的源码包,如需使用请联系相关销售获取;建议您根据“文档中心 – 寒武纪开发者社区 (cambricon.com)”提示进行部署。展开谢谢谢谢已解决
0
Github
开发平台
文档中心
新手必读
官方微信
版权所有 © 2024 寒武纪 Cambricon.com 备案/许可证号:
京ICP备17003415号-1
关闭