小编Nic*_*tti的帖子

Cuda在Visual Studio中生成并行代码

我在Visual Studio 2012解决方案中有几个C++项目.这些项目包含大量文件,我使用/ MP来加速代码生成.

我想知道是否有办法以类似的方式加速NVCC.在包含CUDA内核的项目中使用/ MP在编译时没有任何好处,我只能看到一个核心在工作.

所以问题是:如何使用我的多核PC来加速CUDA编译?

c++ cuda compilation visual-studio compilation-time

11
推荐指数
1
解决办法
2796
查看次数

GMail API Python 和编码/解码

我正在尝试使用Google 提供的API使用 Python 3.4读取我的 GMail 消息。

我正在使用 Google 在链接上提供的此功能:

def GetMimeMessage(service, user_id, msg_id):

  try:
    message = service.users().messages().get(userId=user_id, id=msg_id,
                                             format='raw').execute()

    print 'Message snippet: %s' % message['snippet']

    msg_str = base64.urlsafe_b64decode(message['raw'].encode('ASCII'))

    mime_msg = email.message_from_string(msg_str)

    return mime_msg
  except errors.HttpError, error:
    print 'An error occurred: %s' % error
Run Code Online (Sandbox Code Playgroud)

但是,如果我按原样使用此功能,则会出现以下错误:

类型错误:initial_value 必须是 str 或 None,而不是字节

所以我稍微改变了函数:

def GetMimeMessage(service, user_id, msg_id):
    try:
       message = service.users().messages().get(userId=user_id, id=msg_id,
                                             format='raw').execute()
       #print ('Message snippet: %s' % message['snippet'])

       msg_str = base64.urlsafe_b64decode(message['raw'].encode('utf-8','ignore'))
       print(msg_str)
       mime_msg = email.message_from_string(msg_str.decode('utf-8','ignore'))

       return mime_msg
   except …
Run Code Online (Sandbox Code Playgroud)

python utf-8 python-3.4 gmail-api

5
推荐指数
1
解决办法
1711
查看次数