import numpy as np from mxnet import nd from mxnet.gluon import nn from mxnet.base import MXNetError from mxnet.test_utils import download, is_cd_run, assert_almost_equal, default_context import pytest base_path = os.path.join(os.path.dirname(__file__), "../../..") def check_platform(): return platform.machine() not in ['x86_64', 'AMD64'] @pytest.mark.skipif(check_platform(), reason="not all machine types supported") @pytest.mark.skipif(is_cd_run(), reason="continuous delivery run - ignoring test") def test_custom_op_gpu(): # possible places to find library file if (os.name == 'posix'): lib = 'libcustomop_gpu_lib.so' if os.path.exists(lib): fname = lib elif os.path.exists(os.path.join(base_path, 'build/' + lib)): fname = os.path.join(base_path, 'build/' + lib) else: raise MXNetError("library %s not found " % lib) elif (os.name == 'nt'): lib = 'libcustomop_gpu_lib.dll' if os.path.exists('windows_package\\lib\\' + lib): fname = 'windows_package\\lib\\' + lib
import os import platform import mxnet as mx import numpy as np from mxnet import nd from mxnet.gluon import nn from mxnet.base import MXNetError from mxnet.test_utils import download, is_cd_run, assert_almost_equal, default_context import pytest base_path = os.path.join(os.path.dirname(__file__), "../../..") def check_platform(supported_platforms=['x86_64', 'AMD64']): return platform.machine() not in supported_platforms @pytest.mark.skipif(check_platform(), reason="not all machine types supported") @pytest.mark.skipif(is_cd_run(), reason="continuous delivery run - ignoring test") def test_custom_op(): # possible places to find library file if (os.name=='posix'): lib = 'libcustomop_lib.so' if os.path.exists(lib): fname = lib elif os.path.exists(os.path.join(base_path,'build/'+lib)): fname = os.path.join(base_path,'build/'+lib) else: raise MXNetError("library %s not found " % lib) elif (os.name=='nt'): lib = 'libcustomop_lib.dll' if os.path.exists('windows_package\\lib\\'+lib): fname = 'windows_package\\lib\\'+lib else:
'Attribute Name']: assert row['Requested Size'] == expected_alloc_entry['Requested Size'], \ "requested size={} is not equal to the expected size={}" \ .format(row['Requested Size'], expected_alloc_entry['Requested Size']) entry_found = True break assert entry_found, \ "Entry for attr_name={} has not been found" \ .format(expected_alloc_entry['Attribute Name']) @pytest.mark.skipif( mx.context.num_gpus() == 0, reason="GPU memory profiler records allocation on GPUs only") @pytest.mark.skipif(is_cd_run(), reason="flaky test - open issue #18564") def test_gpu_memory_profiler_gluon(): enable_profiler(profile_filename='test_profiler.json', run=True, continuous_dump=True) profiler.set_state('run') model = nn.HybridSequential(prefix='net_') with model.name_scope(): model.add(nn.Dense(128, activation='tanh')) model.add(nn.Dropout(0.5)) model.add(nn.Dense(64, activation='tanh'), nn.Dense(32, in_units=64)) model.add(nn.Activation('relu')) model.initialize(ctx=mx.gpu()) model.hybridize()
import mxnet as mx import numpy as np from mxnet import nd from mxnet.gluon import nn from mxnet.base import MXNetError from mxnet.test_utils import download, is_cd_run, assert_almost_equal, default_context base_path = os.path.join(os.path.dirname(__file__), "../../..") def check_platform(): return platform.machine() not in ['x86_64', 'AMD64'] @unittest.skipIf(check_platform(), "not all machine types supported") @unittest.skipIf(is_cd_run(), "continuous delivery run - ignoring test") def test_custom_op_gpu(): # possible places to find library file if (os.name == 'posix'): lib = 'libcustomop_gpu_lib.so' if os.path.exists(lib): fname = lib elif os.path.exists(os.path.join(base_path, 'build/' + lib)): fname = os.path.join(base_path, 'build/' + lib) else: raise MXNetError("library %s not found " % lib) elif (os.name == 'nt'): lib = 'libcustomop_gpu_lib.dll' if os.path.exists('windows_package\\lib\\' + lib): fname = 'windows_package\\lib\\' + lib else: