{"action":"created","issue":{"url":"https://api.github.com/repos/dmlc/mxnet/issues/788","labels_url":"https://api.github.com/repos/dmlc/mxnet/issues/788/labels{/name}","comments_url":"https://api.github.com/repos/dmlc/mxnet/issues/788/comments","events_url":"https://api.github.com/repos/dmlc/mxnet/issues/788/events","html_url":"https://github.com/dmlc/mxnet/issues/788","id":119991283,"number":788,"title":"Some gpu/cpu related questions","user":{"login":"suhangpro","id":1848396,"avatar_url":"https://avatars.githubusercontent.com/u/1848396?v=3","gravatar_id":"","url":"https://api.github.com/users/suhangpro","html_url":"https://github.com/suhangpro","followers_url":"https://api.github.com/users/suhangpro/followers","following_url":"https://api.github.com/users/suhangpro/following{/other_user}","gists_url":"https://api.github.com/users/suhangpro/gists{/gist_id}","starred_url":"https://api.github.com/users/suhangpro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suhangpro/subscriptions","organizations_url":"https://api.github.com/users/suhangpro/orgs","repos_url":"https://api.github.com/users/suhangpro/repos","events_url":"https://api.github.com/users/suhangpro/events{/privacy}","received_events_url":"https://api.github.com/users/suhangpro/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-02T17:13:54Z","updated_at":"2015-12-02T20:45:00Z","closed_at":null,"body":"##### symbol binding\r\nNDArray can be created on the device of choice, and the binding function also takes a 'ctx' as parameter. What's the intended behavior if they are declared different? \r\n\r\nFor instance, here a and b are created on gpu(0) but the context of the generated executor is cpu(), where will the work be done on? The output is on gpu(0). The same happens in reverse: the output will be on cpu() if a and b are on cpu(0) no matter what the 'ctx' is. \r\n```python\r\nA = mx.symbol.Variable('A')\r\nB = mx.symbol.Variable('B')\r\nC = A * B\r\na = mx.nd.ones(3,mx.gpu(0)) * 4\r\nb = mx.nd.ones(3,mx.gpu(0)) * 2\r\nc_exec = C.bind(ctx=mx.cpu(), args={'A' : a, 'B': b})\r\nc_exec.forward()\r\nc_exec.outputs[0].context # --> gpu(0)\r\n```\r\n\r\n##### model api\r\nThe model api also takes 'ctx' parameter. The model below has parameters on cpu(0) and 'ctx' declared as gpu(0). This time seems the 'ctx' parameter has higher priority. \r\n``` python\r\nmodel = mx.model.FeedForward(\r\n        ctx                = mx.gpu(0), # mx.gpu(0)\r\n        symbol             = network,\r\n        num_epoch          = args.num_epochs,\r\n        learning_rate      = args.lr,\r\n        momentum           = 0.9,\r\n        wd                 = 0.00001,\r\n        initializer        = mx.init.Xavier(factor_type=\"in\", magnitude=2.34),\r\n        arg_params         = mx.model.FeedForward.load('vgg19',1).arg_params) # mx.cpu()\r\n```\r\n\r\n##### multiple cpus\r\nThis might be a silly question, but I cannot find any related information in the documents. Like NDArray can be created on the gpu of choice (gpu(0), gpu(1) ...), is there any distinctions between cpu cores (cpu(0), cpu(1) ...)? \r\n\r\nIn [example code](https://github.com/suhangpro/mxnet/blob/master/example/image-classification/train_model.py#L32) I see this:  \r\n``` python\r\n    devs = mx.cpu() if args.gpus is None else [\r\n        mx.gpu(int(i)) for i in args.gpus.split(',')]\r\n```\r\nHere only cpu(0) is declared for 'devs' for cpu-only mode. Can mxnet uses **all the cpu cores** on my machine? "},"comment":{"url":"https://api.github.com/repos/dmlc/mxnet/issues/comments/161428905","html_url":"https://github.com/dmlc/mxnet/issues/788#issuecomment-161428905","issue_url":"https://api.github.com/repos/dmlc/mxnet/issues/788","id":161428905,"user":{"login":"jermainewang","id":4057701,"avatar_url":"https://avatars.githubusercontent.com/u/4057701?v=3","gravatar_id":"","url":"https://api.github.com/users/jermainewang","html_url":"https://github.com/jermainewang","followers_url":"https://api.github.com/users/jermainewang/followers","following_url":"https://api.github.com/users/jermainewang/following{/other_user}","gists_url":"https://api.github.com/users/jermainewang/gists{/gist_id}","starred_url":"https://api.github.com/users/jermainewang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jermainewang/subscriptions","organizations_url":"https://api.github.com/users/jermainewang/orgs","repos_url":"https://api.github.com/users/jermainewang/repos","events_url":"https://api.github.com/users/jermainewang/events{/privacy}","received_events_url":"https://api.github.com/users/jermainewang/received_events","type":"User","site_admin":false},"created_at":"2015-12-02T20:45:00Z","updated_at":"2015-12-02T20:45:00Z","body":"Hi,\r\n\r\nThank you for your question. For CPU, you could not specify the device id. The device id is only used for GPU. MXNet uses multi-threaded engine to utilize the multi-core power. You could set `MXNET_CPU_WORKER_NTHREADS` environment variable to specify how many threads (roughly how many cores) you would like to use."}}